PluginProbe
Property Hive / 2.4.0
Property Hive v2.4.0
2.4.0 2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 All 262 releases
← All changes | includes/class-ph-sale.php +153 -1 1.4.47 → 2.4.0 View file →
@@ -12,8 +12,9 @@
12 12 * @package PropertyHive/Classes
13 13 * @category Class
14 14 * @author PropertyHive
15 15 */
16 +// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Legacy public global class PH_Sale; preserving the existing PH_* class name is required for plugin and extension compatibility.
16 17 class PH_Sale {
17 18
18 19 /** @public int Sale (post) ID */
19 20 public $id;
@@ -103,8 +104,159 @@
103 104 public function get_formatted_amount( ) {
104 105
105 106 $amount = $this->_amount;
106 107 $prefix = '£';
107 - return ( ( $amount != '' ) ? $prefix . number_format($amount , 0) : '-' );
108 + return ( ( $amount != '' ) ? $prefix . ph_display_price_field($amount) : '-' );
108 109
110 + }
111 +
112 + /**
113 + * Get a list of applicants on the sale
114 + *
115 + * @access public
116 + * @param bool $add_hyperlinks
117 + * @param bool $additional_contact_details
118 + * @param bool $contact_details_visible
119 + * @return array
120 + */
121 + public function get_applicants( $add_hyperlinks = false, $additional_contact_details = false, $contact_details_visible = true )
122 + {
123 + $applicant_contact_ids = get_post_meta( $this->id, '_applicant_contact_id' );
124 + if ( is_array($applicant_contact_ids) && !empty($applicant_contact_ids) )
125 + {
126 + $applicants = array();
127 + foreach ( $applicant_contact_ids as $applicant_contact_id )
128 + {
129 + $applicant_name = esc_html( get_the_title( $applicant_contact_id ) );
130 + if ( $add_hyperlinks )
131 + {
132 + $edit_link = get_edit_post_link( $applicant_contact_id );
133 + $applicant_name = '<a href="' . esc_url( $edit_link ) . '">' . $applicant_name . '</a>';
134 + }
135 + if ( $additional_contact_details )
136 + {
137 + $contact_details = array();
138 + $telephone_number = get_post_meta( $applicant_contact_id, '_telephone_number', true );
139 + if( !empty($telephone_number) )
140 + {
141 + $contact_details[] = 'T: ' . esc_html( $telephone_number );
142 + }
143 +
144 + $email_address = get_post_meta( $applicant_contact_id, '_email_address', true );
145 + if( !empty($email_address) )
146 + {
147 + $contact_details[] = 'E: ' . esc_html( $email_address );
148 + }
149 +
150 + $contact_details = apply_filters( 'propertyhive_sale_applicant_contact_details', $contact_details, $applicant_contact_id );
151 +
152 + if ( !empty($contact_details) )
153 + {
154 + $applicant_name .= '<div class="row-actions' . ($contact_details_visible ? ' visible' : '') . '">' . implode( "<br>", $contact_details ) . '</div>';
155 + }
156 + }
157 + $applicants[] = $applicant_name;
158 + }
159 + return implode("<br>", $applicants);
160 + }
161 + else
162 + {
163 + return '-';
164 + }
165 + }
166 +
167 + /**
168 + * Get the full address of the property attached to the sale
169 + *
170 + * @access public
171 + * @return string
172 + */
173 + public function get_property_address()
174 + {
175 + $property_id = (int)$this->_property_id;
176 +
177 + if ( !empty($property_id) )
178 + {
179 + $property = new PH_Property( $property_id );
180 + return '<a href="' . esc_url( get_edit_post_link( $property_id, '' ) ) . '" target="' . esc_attr( apply_filters('propertyhive_subgrid_link_target', '') ) . '">' . esc_html( $property->get_formatted_full_address() ) . '</a>';
181 + }
182 + else
183 + {
184 + return '-';
185 + }
186 + }
187 +
188 + /**
189 + * Get the contact details of the owner(s) of the property attached to the sale
190 + *
191 + * @access public
192 + * @return string
193 + */
194 + public function get_property_owners()
195 + {
196 + $property_owners = '-';
197 +
198 + $property_id = (int)$this->_property_id;
199 +
200 + if ( !empty($property_id) )
201 + {
202 + $property = new PH_Property( $property_id );
203 + $owner_contact_ids = $property->_owner_contact_id;
204 + if (
205 + ( !is_array($owner_contact_ids) && $owner_contact_ids != '' && $owner_contact_ids != 0 )
206 + ||
207 + ( is_array($owner_contact_ids) && !empty($owner_contact_ids) )
208 + )
209 + {
210 + $property_owners = '';
211 +
212 + if ( !is_array($owner_contact_ids) )
213 + {
214 + $owner_contact_ids = array($owner_contact_ids);
215 + }
216 +
217 + foreach ( $owner_contact_ids as $owner_contact_id )
218 + {
219 + $property_owners .= $this->formatted_contact_meta_box_data($owner_contact_id, false);
220 + }
221 + }
222 + }
223 +
224 + return $property_owners;
225 + }
226 +
227 + /**
228 + * Format contact data for display in a meta box list
229 + */
230 + private function formatted_contact_meta_box_data( $contact_post_id, $add_edit_link = true )
231 + {
232 + if ( $add_edit_link )
233 + {
234 + $contact_text = '<a href="' . esc_url( get_edit_post_link( $contact_post_id, '' ) ) . '" target="' . esc_attr( apply_filters('propertyhive_subgrid_link_target', '') ) . '">' . esc_html( get_the_title($contact_post_id) ) . '</a>';
235 + }
236 + else
237 + {
238 + $contact_text = esc_html( get_the_title($contact_post_id) );
239 + }
240 +
241 + $contact_details = '';
242 + $telephone_number = get_post_meta( $contact_post_id, '_telephone_number', true );
243 + if( !empty($telephone_number) )
244 + {
245 + $contact_details = 'T: ' . esc_html($telephone_number);
246 + }
247 +
248 + $email_address = get_post_meta( $contact_post_id, '_email_address', true );
249 + if( !empty($email_address) )
250 + {
251 + $contact_details .= ( $contact_details != '' ) ? '<br>' : '';
252 + $contact_details .= 'E: ' . esc_html($email_address);
253 + }
254 +
255 + if ( $contact_details != '' )
256 + {
257 + $contact_text .= '<div class="row-actions visible">' . $contact_details . '</div>';
258 + }
259 +
260 + return $contact_text;
109 261 }
110 262 }