/**
  * Save meta box data
  */
 public static function save($post_id, $post)
 {
     global $wpdb;
     // Only save meta info if department is 'residential-lettings'
     $department = get_post_meta($post_id, '_department', TRUE);
     if ($department == 'residential-lettings') {
         update_post_meta($post_id, '_currency', $_POST['_rent_currency']);
         $rent = preg_replace("/[^0-9.]/", '', $_POST['_rent']);
         update_post_meta($post_id, '_rent', $rent);
         update_post_meta($post_id, '_rent_frequency', $_POST['_rent_frequency']);
         // Store price in common currency (GBP) and frequency (PCM) used for ordering
         $ph_countries = new PH_Countries();
         $ph_countries->update_property_price_actual($post_id);
         update_post_meta($post_id, '_poa', isset($_POST['_rent_poa']) ? $_POST['_rent_poa'] : '');
         update_post_meta($post_id, '_deposit', preg_replace("/[^0-9.]/", '', $_POST['_deposit']));
         update_post_meta($post_id, '_available_date', $_POST['_available_date']);
         if (!empty($_POST['furnished_id'])) {
             wp_set_post_terms($post_id, $_POST['furnished_id'], 'furnished');
         } else {
             // Setting to blank
             wp_delete_object_term_relationships($post_id, 'furnished');
         }
         do_action('propertyhive_save_property_residential_lettings_details', $post_id);
     }
 }
 /**
  * Save meta box data
  */
 public static function save($post_id, $post)
 {
     global $wpdb;
     // Only save meta info if department is 'commercial'
     $department = get_post_meta($post_id, '_department', TRUE);
     if ($department == 'commercial') {
         update_post_meta($post_id, '_for_sale', '');
         update_post_meta($post_id, '_to_rent', '');
         if (isset($_POST['_available_as']) && !empty($_POST['_available_as'])) {
             if (in_array('sale', $_POST['_available_as'])) {
                 update_post_meta($post_id, '_for_sale', 'yes');
                 update_post_meta($post_id, '_commercial_price_currency', $_POST['_commercial_price_currency']);
                 $price = preg_replace("/[^0-9.]/", '', $_POST['_price_from']);
                 if ($price == '') {
                     $price = preg_replace("/[^0-9.]/", '', $_POST['_price_to']);
                 }
                 update_post_meta($post_id, '_price_from', $price);
                 $price = preg_replace("/[^0-9.]/", '', $_POST['_price_to']);
                 if ($price == '') {
                     $price = preg_replace("/[^0-9.]/", '', $_POST['_price_from']);
                 }
                 update_post_meta($post_id, '_price_to', $price);
                 update_post_meta($post_id, '_price_units', $_POST['_price_units']);
                 update_post_meta($post_id, '_price_poa', isset($_POST['_commercial_price_poa']) ? $_POST['_commercial_price_poa'] : '');
                 if (!empty($_POST['commercial_price_qualifier_id'])) {
                     wp_set_post_terms($post_id, $_POST['commercial_price_qualifier_id'], 'price_qualifier');
                 } else {
                     // Setting to blank
                     wp_delete_object_term_relationships($post_id, 'price_qualifier');
                 }
                 if (!empty($_POST['commercial_sale_by_id'])) {
                     wp_set_post_terms($post_id, $_POST['commercial_sale_by_id'], 'sale_by');
                 } else {
                     // Setting to blank
                     wp_delete_object_term_relationships($post_id, 'sale_by');
                 }
                 if (!empty($_POST['commercial_tenure_id'])) {
                     wp_set_post_terms($post_id, $_POST['commercial_tenure_id'], 'commercial_tenure');
                 } else {
                     // Setting to blank
                     wp_delete_object_term_relationships($post_id, 'commercial_tenure');
                 }
             }
             if (in_array('rent', $_POST['_available_as'])) {
                 update_post_meta($post_id, '_to_rent', 'yes');
                 update_post_meta($post_id, '_commercial_rent_currency', $_POST['_commercial_rent_currency']);
                 $rent = preg_replace("/[^0-9.]/", '', $_POST['_rent_from']);
                 if ($rent == '') {
                     $rent = preg_replace("/[^0-9.]/", '', $_POST['_rent_to']);
                 }
                 update_post_meta($post_id, '_rent_from', $rent);
                 $rent = preg_replace("/[^0-9.]/", '', $_POST['_rent_to']);
                 if ($rent == '') {
                     $rent = preg_replace("/[^0-9.]/", '', $_POST['_rent_from']);
                 }
                 update_post_meta($post_id, '_rent_to', $rent);
                 update_post_meta($post_id, '_rent_units', $_POST['_rent_units']);
                 update_post_meta($post_id, '_rent_poa', isset($_POST['_commercial_rent_poa']) ? $_POST['_commercial_rent_poa'] : '');
             }
         }
         // Store price in common currency (GBP) used for ordering
         $ph_countries = new PH_Countries();
         $ph_countries->update_property_price_actual($post_id);
         $property_types = array();
         if (isset($_POST['property_type_ids']) && !empty($_POST['property_type_ids'])) {
             foreach ($_POST['property_type_ids'] as $property_type_id) {
                 $property_types[] = $property_type_id;
             }
         }
         if (!empty($property_types)) {
             wp_set_post_terms($post_id, $property_types, 'commercial_property_type');
         } else {
             wp_delete_object_term_relationships($post_id, 'commercial_property_type');
         }
         $size = preg_replace("/[^0-9.]/", '', $_POST['_floor_area_from']);
         if ($size == '') {
             $size = preg_replace("/[^0-9.]/", '', $_POST['_floor_area_to']);
         }
         update_post_meta($post_id, '_floor_area_from', $size);
         update_post_meta($post_id, '_floor_area_from_sqft', convert_size_to_sqft($size, $_POST['_floor_area_units']));
         $size = preg_replace("/[^0-9.]/", '', $_POST['_floor_area_to']);
         if ($size == '') {
             $size = preg_replace("/[^0-9.]/", '', $_POST['_floor_area_from']);
         }
         update_post_meta($post_id, '_floor_area_to', $size);
         update_post_meta($post_id, '_floor_area_to_sqft', convert_size_to_sqft($size, $_POST['_floor_area_units']));
         update_post_meta($post_id, '_floor_area_units', $_POST['_floor_area_units']);
         $size = preg_replace("/[^0-9.]/", '', $_POST['_site_area_from']);
         if ($size == '') {
             $size = preg_replace("/[^0-9.]/", '', $_POST['_site_area_to']);
         }
         update_post_meta($post_id, '_site_area_from', $size);
         update_post_meta($post_id, '_site_area_from_sqft', convert_size_to_sqft($size, $_POST['_site_area_units']));
         $size = preg_replace("/[^0-9.]/", '', $_POST['_site_area_to']);
         if ($size == '') {
             $size = preg_replace("/[^0-9.]/", '', $_POST['_site_area_from']);
         }
         update_post_meta($post_id, '_site_area_to', $size);
         update_post_meta($post_id, '_site_area_to_sqft', convert_size_to_sqft($size, $_POST['_site_area_units']));
         update_post_meta($post_id, '_site_area_units', $_POST['_site_area_units']);
     }
 }
 /**
  * Save meta box data
  */
 public static function save($post_id, $post)
 {
     global $wpdb;
     // Only save meta info if department is 'residential-sales'
     $department = get_post_meta($post_id, '_department', TRUE);
     if ($department == 'residential-sales') {
         update_post_meta($post_id, '_currency', $_POST['_price_currency']);
         $price = preg_replace("/[^0-9]/", '', $_POST['_price']);
         update_post_meta($post_id, '_price', $price);
         // Store price in common currency (GBP) used for ordering
         $ph_countries = new PH_Countries();
         $ph_countries->update_property_price_actual($post_id);
         update_post_meta($post_id, '_poa', isset($_POST['_sale_poa']) ? $_POST['_sale_poa'] : '');
         if (!empty($_POST['price_qualifier_id'])) {
             wp_set_post_terms($post_id, $_POST['price_qualifier_id'], 'price_qualifier');
         } else {
             // Setting to blank
             wp_delete_object_term_relationships($post_id, 'price_qualifier');
         }
         if (!empty($_POST['sale_by_id'])) {
             wp_set_post_terms($post_id, $_POST['sale_by_id'], 'sale_by');
         } else {
             // Setting to blank
             wp_delete_object_term_relationships($post_id, 'sale_by');
         }
         if (!empty($_POST['tenure_id'])) {
             wp_set_post_terms($post_id, $_POST['tenure_id'], 'tenure');
         } else {
             // Setting to blank
             wp_delete_object_term_relationships($post_id, 'tenure');
         }
         do_action('propertyhive_save_property_residential_sales_details', $post_id);
     }
 }