PluginProbe
Property Hive / 2.3.0
Property Hive v2.3.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 1.4.61 All 261 releases
← All changes | includes/class-ph-offer.php +168 -1 1.4.522.3.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_Offer; preserving the existing PH_* class name is required for plugin and extension compatibility.
16 17 class PH_Offer {
17 18
18 19 /** @public int Offer (post) ID */
19 20 public $id;
@@ -103,8 +104,174 @@
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 offer
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_offer_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 + public function get_applicant_ids()
168 + {
169 + $applicant_contact_ids = get_post_meta( $this->id, '_applicant_contact_id' );
170 + if ( $applicant_contact_ids == '' )
171 + {
172 + $applicant_contact_ids = array();
173 + }
174 + if ( !is_array($applicant_contact_ids) && $applicant_contact_ids != '' && $applicant_contact_ids != 0 )
175 + {
176 + $applicant_contact_ids = array($applicant_contact_ids);
177 + }
178 +
179 + return $applicant_contact_ids;
180 + }
181 +
182 + /**
183 + * Get the full address of the property attached to the offer
184 + *
185 + * @access public
186 + * @return string
187 + */
188 + public function get_property_address()
189 + {
190 + $property_id = (int)$this->_property_id;
191 +
192 + if ( !empty($property_id) )
193 + {
194 + $property = new PH_Property( $property_id );
195 + 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>';
196 + }
197 + else
198 + {
199 + return '-';
200 + }
201 + }
202 +
203 + /**
204 + * Get the contact details of the owner(s) of the property attached to the offer
205 + *
206 + * @access public
207 + * @return string
208 + */
209 + public function get_property_owners()
210 + {
211 + $property_owners = '-';
212 +
213 + $property_id = (int)$this->_property_id;
214 +
215 + if ( !empty($property_id) )
216 + {
217 + $property = new PH_Property( $property_id );
218 + $owner_contact_ids = $property->_owner_contact_id;
219 + if (
220 + ( !is_array($owner_contact_ids) && $owner_contact_ids != '' && $owner_contact_ids != 0 )
221 + ||
222 + ( is_array($owner_contact_ids) && !empty($owner_contact_ids) )
223 + )
224 + {
225 + $property_owners = '';
226 +
227 + if ( !is_array($owner_contact_ids) )
228 + {
229 + $owner_contact_ids = array($owner_contact_ids);
230 + }
231 +
232 + foreach ( $owner_contact_ids as $owner_contact_id )
233 + {
234 + $property_owners .= $this->formatted_contact_meta_box_data($owner_contact_id, false);
235 + }
236 + }
237 + }
238 +
239 + return $property_owners;
240 + }
241 +
242 + /**
243 + * Format contact data for display in a meta box list
244 + */
245 + private function formatted_contact_meta_box_data( $contact_post_id, $add_edit_link = true )
246 + {
247 + if ( $add_edit_link )
248 + {
249 + $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>';
250 + }
251 + else
252 + {
253 + $contact_text = esc_html( get_the_title($contact_post_id) );
254 + }
255 +
256 + $contact_details = '';
257 + $telephone_number = get_post_meta( $contact_post_id, '_telephone_number', true );
258 + if( !empty($telephone_number) )
259 + {
260 + $contact_details = 'T: ' . esc_html($telephone_number);
261 + }
262 +
263 + $email_address = get_post_meta( $contact_post_id, '_email_address', true );
264 + if( !empty($email_address) )
265 + {
266 + $contact_details .= ( $contact_details != '' ) ? '<br>' : '';
267 + $contact_details .= 'E: ' . esc_html($email_address);
268 + }
269 +
270 + if ( $contact_details != '' )
271 + {
272 + $contact_text .= '<div class="row-actions visible">' . $contact_details . '</div>';
273 + }
274 +
275 + return $contact_text;
109 276 }
110 277 }