0 ) { $this->get_offer( $id ); } } /** * Gets a offer from the database. * * @access public * @param int $id (default: 0) * @return bool */ public function get_offer( $id = 0 ) { if ( ! $id ) { return false; } if ( $result = get_post( $id ) ) { $this->populate( $result ); return true; } return false; } /** * __isset function. * * @access public * @param mixed $key * @return bool */ public function __isset( $key ) { if ( ! $this->id ) { return false; } return metadata_exists( 'post', $this->id, '_' . $key ); } /** * __get function. * * @access public * @param mixed $key * @return mixed */ public function __get( $key ) { // Get values or default if not set $value = get_post_meta( $this->id, $key, true ); if ($value == '') { $value = get_post_meta( $this->id, '_' . $key, true ); } return $value; } /** * Populates a offer from the loaded post data. * * @access public * @param mixed $result * @return void */ public function populate( $result ) { // Standard post data $this->id = $result->ID; $this->post_title = $result->post_title; $this->post_status = $result->post_status; } /** * Get the formatted offer amount * * @access public * @return string */ public function get_formatted_amount( ) { $amount = $this->_amount; $prefix = '£'; return ( ( $amount != '' ) ? $prefix . ph_display_price_field($amount) : '-' ); } /** * Get a list of applicants on the offer * * @access public * @param bool $add_hyperlinks * @param bool $additional_contact_details * @param bool $contact_details_visible * @return array */ public function get_applicants( $add_hyperlinks = false, $additional_contact_details = false, $contact_details_visible = true ) { $applicant_contact_ids = get_post_meta( $this->id, '_applicant_contact_id' ); if ( is_array($applicant_contact_ids) && !empty($applicant_contact_ids) ) { $applicants = array(); foreach ( $applicant_contact_ids as $applicant_contact_id ) { $applicant_name = get_the_title($applicant_contact_id); if ( $add_hyperlinks ) { $edit_link = get_edit_post_link( $applicant_contact_id ); $applicant_name = '' . $applicant_name . ''; } if ( $additional_contact_details ) { $contact_details = array(); $telephone_number = get_post_meta( $applicant_contact_id, '_telephone_number', true ); if( !empty($telephone_number) ) { $contact_details[] = 'T: ' . $telephone_number; } $email_address = get_post_meta( $applicant_contact_id, '_email_address', true ); if( !empty($email_address) ) { $contact_details[] = 'E: ' . $email_address; } $contact_details = apply_filters( 'propertyhive_offer_applicant_contact_details', $contact_details, $applicant_contact_id ); if ( !empty($contact_details) ) { $applicant_name .= '