PluginProbe
Property Hive / 1.4.53
Property Hive v1.4.53
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 1.4.62 All 260 releases
propertyhive / includes / admin / post-types / class-ph-admin-meta-boxes.php

class-ph-admin-meta-boxes.php in Property Hive 1.4.53, at includes/admin/post-types/class-ph-admin-meta-boxes.php

1,757 lines 72.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PropertyHive Meta Boxes
4 *
5 * Sets up the write panels used by products and orders (custom post types)
6 *
7 * @author BIOSTA::
8 * @category Admin
9 * @package PropertyHive/Admin/Meta Boxes
10 * @version 1.0.0
11 */
12
13 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
14
15 if ( ! class_exists( 'PH_Admin_Meta_Boxes' ) )
16 {
17
18 /**
19 * PH_Admin_Meta_Boxes
20 */
21 class PH_Admin_Meta_Boxes {
22
23 private static $meta_box_errors = array();
24
25 /**
26 * Constructor
27 */
28 public function __construct() {
29
30 add_action( 'add_meta_boxes', array( $this, 'remove_meta_boxes' ), 10 );
31 add_action( 'add_meta_boxes', array( $this, 'rename_meta_boxes' ), 20 );
32 add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 30 );
33 add_action( 'save_post', array( $this, 'save_meta_boxes' ), 1, 2 );
34
35 // Save Property Meta Boxes
36 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Address::save', 10, 2 );
37 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Owner::save', 12, 2 );
38 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Record_Details::save', 13, 2 );
39 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Coordinates::save', 70, 2 );
40
41 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Department::save', 15, 2 );
42 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Residential_Details::save', 20, 2 );
43 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Residential_Lettings_Details::save', 25, 2 );
44 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Residential_Sales_Details::save', 30, 2 );
45 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Commercial_Details::save', 30, 2 );
46
47 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Marketing::save', 35, 2 );
48
49 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Rooms::save', 40, 2 );
50 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Features::save', 45, 2 );
51 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Description::save', 45, 2 );
52
53 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Photos::save', 50, 2 );
54 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Floorplans::save', 55, 2 );
55 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Brochures::save', 65, 2 );
56 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Epcs::save', 70, 2 );
57 add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Virtual_Tours::save', 75, 2 );
58
59 // Save Contact Meta Boxes
60 if ( isset($_POST['_contact_type_new']) )
61 {
62 add_action( 'propertyhive_process_contact_meta', 'PH_Meta_Box_Contact_New_Relationship::save', 1, 2 );
63 }
64 add_action( 'propertyhive_process_contact_meta', 'PH_Meta_Box_Contact_Correspondence_Address::save', 10, 2 );
65 add_action( 'propertyhive_process_contact_meta', 'PH_Meta_Box_Contact_Contact_Details::save', 15, 2 );
66 if ( !isset($_POST['_contact_type_new']) )
67 {
68 add_action( 'propertyhive_process_contact_meta', 'PH_Meta_Box_Contact_Relationships::save', 20, 2 );
69 }
70
71 // Save Enquiry Meta Boxes
72 if ( get_option('propertyhive_module_disabled_enquiries', '') != 'yes' )
73 {
74 add_action( 'propertyhive_process_enquiry_meta', 'PH_Meta_Box_Enquiry_Record_Details::save', 10, 2 );
75 add_action( 'propertyhive_process_enquiry_meta', 'PH_Meta_Box_Enquiry_Details::save', 15, 2 );
76 }
77
78 // Save Appraisal Meta Boxes
79 add_action( 'propertyhive_process_appraisal_meta', 'PH_Meta_Box_Appraisal_Details::save', 10, 2 );
80 add_action( 'propertyhive_process_appraisal_meta', 'PH_Meta_Box_Appraisal_Event::save', 15, 2 );
81 add_action( 'propertyhive_process_appraisal_meta', 'PH_Meta_Box_Appraisal_Property_Owner::save', 20, 2 );
82 add_action( 'propertyhive_process_appraisal_meta', 'PH_Meta_Box_Appraisal_Property::save', 25, 2 );
83
84 // Save Viewing Meta Boxes
85 add_action( 'propertyhive_process_viewing_meta', 'PH_Meta_Box_Viewing_Details::save', 10, 2 );
86 add_action( 'propertyhive_process_viewing_meta', 'PH_Meta_Box_Viewing_Event::save', 15, 2 );
87 add_action( 'propertyhive_process_viewing_meta', 'PH_Meta_Box_Viewing_Applicant::save', 20, 2 );
88 add_action( 'propertyhive_process_viewing_meta', 'PH_Meta_Box_Viewing_Property::save', 25, 2 );
89
90 // Save Offer Meta Boxes
91 add_action( 'propertyhive_process_offer_meta', 'PH_Meta_Box_Offer_Details::save', 10, 2 );
92 add_action( 'propertyhive_process_offer_meta', 'PH_Meta_Box_Offer_Applicant::save', 15, 2 );
93 add_action( 'propertyhive_process_offer_meta', 'PH_Meta_Box_Offer_Applicant_Solicitor::save', 20, 2 );
94 add_action( 'propertyhive_process_offer_meta', 'PH_Meta_Box_Offer_Property::save', 25, 2 );
95 add_action( 'propertyhive_process_offer_meta', 'PH_Meta_Box_Offer_Property_Owner_Solicitor::save', 30, 2 );
96
97 // Save Sale Meta Boxes
98 add_action( 'propertyhive_process_sale_meta', 'PH_Meta_Box_Sale_Details::save', 10, 2 );
99 add_action( 'propertyhive_process_sale_meta', 'PH_Meta_Box_Sale_Applicant_Solicitor::save', 15, 2 );
100 add_action( 'propertyhive_process_sale_meta', 'PH_Meta_Box_Sale_Property_Owner_Solicitor::save', 20, 2 );
101
102 // Error handling (for showing errors from meta boxes on next page load)
103 add_action( 'admin_notices', array( $this, 'output_errors' ) );
104 add_action( 'shutdown', array( $this, 'save_errors' ) );
105
106 add_filter( 'redirect_post_location', array( $this, 'redirect_to_tab' ), 10, 2 );
107
108 $this->check_contact_create_relationship();
109 $this->check_contact_delete_relationship();
110 $this->check_remove_solicitor();
111 $this->check_create_offer();
112 $this->check_create_sale();
113 }
114
115 public function redirect_to_tab( $url, $post_id )
116 {
117 if ( isset($_POST['propertyhive_selected_metabox_tab']) )
118 {
119 $url .= '#' . $_POST['propertyhive_selected_metabox_tab'];
120 }
121
122 return $url;
123 }
124
125 public function check_contact_create_relationship()
126 {
127 if ( isset($_GET['add_applicant_relationship']) && wp_verify_nonce($_GET['add_applicant_relationship'], '1') && isset($_GET['post']) )
128 {
129 // Need to add blank applicant
130 if ( get_post_type((int)$_GET['post']) != 'contact' )
131 return;
132
133 $num_applicant_profiles = get_post_meta( (int)$_GET['post'], '_applicant_profiles', TRUE );
134 if ( $num_applicant_profiles == '' )
135 {
136 $num_applicant_profiles = 0;
137 }
138
139 update_post_meta( (int)$_GET['post'], '_applicant_profile_' . $num_applicant_profiles, '' );
140 update_post_meta( (int)$_GET['post'], '_applicant_profiles', $num_applicant_profiles + 1 );
141
142 $existing_contact_types = get_post_meta( (int)$_GET['post'], '_contact_types', TRUE );
143 if ( $existing_contact_types == '' || !is_array($existing_contact_types) )
144 {
145 $existing_contact_types = array();
146 }
147 if ( !in_array( 'applicant', $existing_contact_types ) )
148 {
149 $existing_contact_types[] = 'applicant';
150 update_post_meta( (int)$_GET['post'], '_contact_types', $existing_contact_types );
151 }
152
153 // Do redirect
154 wp_redirect( admin_url( 'post.php?post=' . (int)$_GET['post'] . '&action=edit#propertyhive-contact-relationships' ) );
155 exit();
156 }
157
158 if ( isset($_GET['add_third_party_relationship']) && wp_verify_nonce($_GET['add_third_party_relationship'], '1') && isset($_GET['post']) )
159 {
160 // Need to add blank applicant
161 if ( get_post_type((int)$_GET['post']) != 'contact' )
162 return;
163
164 $existing_third_party_categories = get_post_meta( (int)$_GET['post'], '_third_party_categories', TRUE );
165 if ($existing_third_party_categories)
166 {
167 $existing_third_party_categories = array();
168 }
169 $existing_third_party_categories[] = 0;
170 update_post_meta( $_GET['post'], '_third_party_categories', $existing_third_party_categories );
171
172 $existing_contact_types = get_post_meta( (int)$_GET['post'], '_contact_types', TRUE );
173 if ( $existing_contact_types == '' || !is_array($existing_contact_types) )
174 {
175 $existing_contact_types = array();
176 }
177 if ( !in_array( 'thirdparty', $existing_contact_types ) )
178 {
179 $existing_contact_types[] = 'thirdparty';
180 update_post_meta( (int)$_GET['post'], '_contact_types', $existing_contact_types );
181 }
182 }
183 }
184
185 public function check_contact_delete_relationship()
186 {
187 if ( isset($_GET['delete_applicant_relationship']) && isset($_GET['post']) )
188 {
189 // Need to add blank applicant
190 if ( get_post_type((int)$_GET['post']) != 'contact' )
191 return;
192
193 $num_applicant_profiles = get_post_meta( (int)$_GET['post'], '_applicant_profiles', TRUE );
194 if ( $num_applicant_profiles == '' )
195 {
196 $num_applicant_profiles = 0;
197 }
198
199 for ( $i = 0; $i < $num_applicant_profiles; ++$i )
200 {
201 if ( wp_verify_nonce($_GET['delete_applicant_relationship'], $i) )
202 {
203 $deleting_applicant_profile = $i;
204
205 // We're deleting this one
206 delete_post_meta( (int)$_GET['post'], '_applicant_profile_' . $i );
207
208 // Now need to rename any that are higher than $deleting_applicant_profile
209 for ( $j = 0; $j < $num_applicant_profiles; ++$j )
210 {
211 if ( $j > $deleting_applicant_profile )
212 {
213 $this_applicant_profile = get_post_meta( (int)$_GET['post'], '_applicant_profile_' . $j );
214 update_post_meta( (int)$_GET['post'], '_applicant_profile_' . ($j - 1), $this_applicant_profile );
215 delete_post_meta( (int)$_GET['post'], '_applicant_profile_' . $j );
216 }
217 }
218
219 // remove from _contact_types if no more profiles left
220 if ( $num_applicant_profiles == 1 )
221 {
222 $existing_contact_types = get_post_meta( (int)$_GET['post'], '_contact_types', TRUE );
223 if ( $existing_contact_types == '' || !is_array($existing_contact_types) )
224 {
225 $existing_contact_types = array();
226 }
227 if( ( $key = array_search('applicant', $existing_contact_types) ) !== false )
228 {
229 unset($existing_contact_types[$key]);
230 }
231 update_post_meta( (int)$_GET['post'], '_contact_types', $existing_contact_types );
232 }
233
234 update_post_meta( (int)$_GET['post'], '_applicant_profiles', $num_applicant_profiles - 1 );
235
236 // Do redirect
237 wp_redirect( admin_url( 'post.php?post=' . (int)$_GET['post'] . '&action=edit#propertyhive-contact-relationships' ) );
238 exit();
239 }
240 }
241 }
242 }
243
244 public function check_remove_solicitor()
245 {
246 if ( isset($_GET['remove_property_owner_solicitor']) && isset($_GET['post']) )
247 {
248 if ( get_post_type((int)$_GET['post']) != 'offer' && get_post_type((int)$_GET['post']) != 'sale' )
249 return;
250
251 update_post_meta( (int)$_GET['post'], '_property_owner_solicitor_contact_id', '' );
252 }
253
254 if ( isset($_GET['remove_applicant_solicitor']) && isset($_GET['post']) )
255 {
256 if ( get_post_type((int)$_GET['post']) != 'offer' && get_post_type((int)$_GET['post']) != 'sale' )
257 return;
258
259 update_post_meta( (int)$_GET['post'], '_applicant_solicitor_contact_id', '' );
260 }
261 }
262
263 public function check_create_offer()
264 {
265 if ( isset($_GET['create_offer']) && isset($_GET['post']) )
266 {
267 if ( get_post_type((int)$_GET['post']) != 'viewing')
268 return;
269
270 $viewing = new PH_Viewing((int)$_GET['post']);
271
272 $offer_post = array(
273 'post_title' => '',
274 'post_content' => '',
275 'post_type' => 'offer',
276 'post_status' => 'publish',
277 'comment_status' => 'closed',
278 'ping_status' => 'closed',
279 );
280
281 // Insert the post into the database
282 $offer_post_id = wp_insert_post( $offer_post );
283
284 add_post_meta( $offer_post_id, '_status', 'pending' );
285 add_post_meta( $offer_post_id, '_amount', '' );
286 add_post_meta( $offer_post_id, '_applicant_contact_id', $viewing->applicant_contact_id );
287 add_post_meta( $offer_post_id, '_applicant_solicitor_contact_id', '' );
288 add_post_meta( $offer_post_id, '_property_id', $viewing->property_id );
289 add_post_meta( $offer_post_id, '_property_owner_solicitor_contact_id', '' );
290 add_post_meta( $offer_post_id, '_offer_date_time', date("Y-m-d H:i:s") );
291
292 update_post_meta( (int)$_GET['post'], '_offer_id', $offer_post_id );
293 update_post_meta( (int)$_GET['post'], '_status', 'offer_made' );
294
295 $current_user = wp_get_current_user();
296
297 // Add note/comment to viewing
298 $comment = array(
299 'note_type' => 'action',
300 'action' => 'viewing_offer_made',
301 );
302
303 $data = array(
304 'comment_post_ID' => (int)$_GET['post'],
305 'comment_author' => $current_user->display_name,
306 'comment_author_email' => 'propertyhive@noreply.com',
307 'comment_author_url' => '',
308 'comment_date' => date("Y-m-d H:i:s"),
309 'comment_content' => serialize($comment),
310 'comment_approved' => 1,
311 'comment_type' => 'propertyhive_note',
312 );
313 $comment_id = wp_insert_comment( $data );
314
315 // Do redirect
316 wp_redirect( admin_url( 'post.php?post=' . $offer_post_id . '&action=edit' ) );
317 exit();
318 }
319
320 }
321
322 public function check_create_sale()
323 {
324 if ( isset($_GET['create_sale']) && isset($_GET['post']) )
325 {
326 if ( get_post_type((int)$_GET['post']) != 'offer')
327 return;
328
329 $offer = new PH_Offer((int)$_GET['post']);
330
331 $sale_post = array(
332 'post_title' => '',
333 'post_content' => '',
334 'post_type' => 'sale',
335 'post_status' => 'publish',
336 'comment_status' => 'closed',
337 'ping_status' => 'closed',
338 );
339
340 // Insert the post into the database
341 $sale_post_id = wp_insert_post( $sale_post );
342
343 add_post_meta( $sale_post_id, '_status', 'current' );
344 add_post_meta( $sale_post_id, '_amount', $offer->amount );
345 add_post_meta( $sale_post_id, '_applicant_contact_id', $offer->applicant_contact_id );
346 add_post_meta( $sale_post_id, '_applicant_solicitor_contact_id', $offer->applicant_solicitor_contact_id );
347 add_post_meta( $sale_post_id, '_property_id', $offer->property_id );
348 add_post_meta( $sale_post_id, '_property_owner_solicitor_contact_id', $offer->property_owner_solicitor_contact_id );
349 add_post_meta( $sale_post_id, '_sale_date_time', date("Y-m-d H:i:s") );
350
351 update_post_meta( (int)$_GET['post'], '_sale_id', $sale_post_id );
352
353 $current_user = wp_get_current_user();
354
355 // Add note/comment to offer
356 $comment = array(
357 'note_type' => 'action',
358 'action' => 'offer_sale_created',
359 );
360
361 $data = array(
362 'comment_post_ID' => (int)$_GET['post'],
363 'comment_author' => $current_user->display_name,
364 'comment_author_email' => 'propertyhive@noreply.com',
365 'comment_author_url' => '',
366 'comment_date' => date("Y-m-d H:i:s"),
367 'comment_content' => serialize($comment),
368 'comment_approved' => 1,
369 'comment_type' => 'propertyhive_note',
370 );
371 $comment_id = wp_insert_comment( $data );
372
373 // Do redirect
374 wp_redirect( admin_url( 'post.php?post=' . $sale_post_id . '&action=edit' ) );
375 exit();
376 }
377
378 }
379
380 /**
381 * Add an error message
382 * @param string $text
383 */
384 public static function add_error( $text ) {
385 self::$meta_box_errors[] = $text;
386 }
387
388 /**
389 * Save errors to an option
390 */
391 public function save_errors() {
392 update_option( 'propertyhivemeta_box_errors', self::$meta_box_errors );
393 }
394
395 /**
396 * Show any stored error messages.
397 */
398 public function output_errors() {
399
400 $errors = maybe_unserialize( get_option( 'propertyhive_meta_box_errors' ) );
401
402 if ( ! empty( $errors ) ) {
403
404 echo '<div id="propertyhive_errors" class="error fade">';
405 foreach ( $errors as $error ) {
406 echo '<p>' . esc_html( $error ) . '</p>';
407 }
408 echo '</div>';
409
410 // Clear
411 delete_option( 'propertyhive_meta_box_errors' );
412 }
413 }
414
415 /**
416 * Add PH Meta boxes
417 */
418 public function add_meta_boxes() {
419
420 global $tabs, $post, $pagenow;
421
422 // PROPERTY
423 if (!isset($tabs)) $tabs = array();
424
425 /* PROPERTY SUMMARY META BOXES */
426 $meta_boxes = array();
427 $meta_boxes[5] = array(
428 'id' => 'propertyhive-property-address',
429 'title' => __( 'Property Address', 'propertyhive' ),
430 'callback' => 'PH_Meta_Box_Property_Address::output',
431 'screen' => 'property',
432 'context' => 'normal',
433 'priority' => 'high'
434 );
435 if ( get_option('propertyhive_module_disabled_contacts', '') != 'yes' )
436 {
437 $meta_boxes[10] = array(
438 'id' => 'propertyhive-property-owner',
439 'title' => __( 'Property Owner / Landlord', 'propertyhive' ),
440 'callback' => 'PH_Meta_Box_Property_Owner::output',
441 'screen' => 'property',
442 'context' => 'normal',
443 'priority' => 'high'
444 );
445 }
446 $meta_boxes[15] = array(
447 'id' => 'propertyhive-property-record-details',
448 'title' => __( 'Record Details', 'propertyhive' ),
449 'callback' => 'PH_Meta_Box_Property_Record_Details::output',
450 'screen' => 'property',
451 'context' => 'normal',
452 'priority' => 'high'
453 );
454 $meta_boxes[20] = array(
455 'id' => 'propertyhive-property-coordinates',
456 'title' => __( 'Property Location', 'propertyhive' ),
457 'callback' => 'PH_Meta_Box_Property_Coordinates::output',
458 'screen' => 'property',
459 'context' => 'normal',
460 'priority' => 'high'
461 );
462
463 $meta_boxes = apply_filters( 'propertyhive_property_summary_meta_boxes', $meta_boxes );
464 ksort($meta_boxes);
465
466 $ids = array();
467 foreach ($meta_boxes as $meta_box)
468 {
469 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
470 $ids[] = $meta_box['id'];
471 }
472
473 $tabs['tab_summary'] = array(
474 'name' => __( 'Summary', 'propertyhive' ),
475 'metabox_ids' => $ids,
476 'post_type' => 'property'
477 );
478
479
480 /* PROPERTY DETAILS META BOXES */
481 $meta_boxes = array();
482 $meta_boxes[5] = array(
483 'id' => 'propertyhive-property-department',
484 'title' => __( 'Property Department', 'propertyhive' ),
485 'callback' => 'PH_Meta_Box_Property_Department::output',
486 'screen' => 'property',
487 'context' => 'normal',
488 'priority' => 'high'
489 );
490 $meta_boxes[10] = array(
491 'id' => 'propertyhive-property-residential-sales-details',
492 'title' => __( 'Residential Sales Details', 'propertyhive' ),
493 'callback' => 'PH_Meta_Box_Property_Residential_Sales_Details::output',
494 'screen' => 'property',
495 'context' => 'normal',
496 'priority' => 'high'
497 );
498 $meta_boxes[15] = array(
499 'id' => 'propertyhive-property-residential-lettings-details',
500 'title' => __( 'Residential Lettings Details', 'propertyhive' ),
501 'callback' => 'PH_Meta_Box_Property_Residential_Lettings_Details::output',
502 'screen' => 'property',
503 'context' => 'normal',
504 'priority' => 'high'
505 );
506 $meta_boxes[20] = array(
507 'id' => 'propertyhive-property-residential-details',
508 'title' => __( 'Residential Details', 'propertyhive' ),
509 'callback' => 'PH_Meta_Box_Property_Residential_Details::output',
510 'screen' => 'property',
511 'context' => 'normal',
512 'priority' => 'high'
513 );
514 $meta_boxes[25] = array(
515 'id' => 'propertyhive-property-commercial-details',
516 'title' => __( 'Commercial Details', 'propertyhive' ),
517 'callback' => 'PH_Meta_Box_Property_Commercial_Details::output',
518 'screen' => 'property',
519 'context' => 'normal',
520 'priority' => 'high'
521 );
522
523 $meta_boxes = apply_filters( 'propertyhive_property_details_meta_boxes', $meta_boxes );
524 ksort($meta_boxes);
525
526 $ids = array();
527 foreach ($meta_boxes as $meta_box)
528 {
529 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
530 $ids[] = $meta_box['id'];
531 }
532
533 $tabs['tab_details'] = array(
534 'name' => __( 'Details', 'propertyhive' ),
535 'metabox_ids' => $ids,
536 'post_type' => 'property'
537 );
538
539 if ( get_post_meta( $post->ID, '_department', TRUE ) == 'commercial' && isset($post->post_parent) && $post->post_parent == 0 )
540 {
541 $meta_boxes = array();
542 $meta_boxes[5] = array(
543 'id' => 'propertyhive-property-commercial-units',
544 'title' => __( 'Commercial Units', 'propertyhive' ),
545 'callback' => 'PH_Meta_Box_Property_Commercial_Units::output',
546 'screen' => 'property',
547 'context' => 'normal',
548 'priority' => 'high'
549 );
550
551 $meta_boxes = apply_filters( 'propertyhive_property_commercial_units_meta_boxes', $meta_boxes );
552 ksort($meta_boxes);
553
554 $ids = array();
555 foreach ($meta_boxes as $meta_box)
556 {
557 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
558 $ids[] = $meta_box['id'];
559 }
560
561 $tabs['tab_units'] = array(
562 'name' => __( 'Units', 'propertyhive' ),
563 'metabox_ids' => $ids,
564 'post_type' => 'property'
565 );
566 }
567
568 /* PROPERTY MARKETING META BOXES */
569 $meta_boxes = array();
570 $meta_boxes[5] = array(
571 'id' => 'propertyhive-property-marketing',
572 'title' => __( 'Property Marketing', 'propertyhive' ),
573 'callback' => 'PH_Meta_Box_Property_Marketing::output',
574 'screen' => 'property',
575 'context' => 'normal',
576 'priority' => 'high'
577 );
578
579 $meta_boxes = apply_filters( 'propertyhive_property_marketing_meta_boxes', $meta_boxes );
580 ksort($meta_boxes);
581
582 $ids = array();
583 foreach ($meta_boxes as $meta_box)
584 {
585 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
586 $ids[] = $meta_box['id'];
587 }
588
589 $tabs['tab_marketing'] = array(
590 'name' => __( 'Marketing', 'propertyhive' ),
591 'metabox_ids' => $ids,
592 'post_type' => 'property'
593 );
594
595 /* PROPERTY DESCRIPTIONS META BOXES */
596 $meta_boxes = array();
597 $meta_boxes[5] = array(
598 'id' => 'propertyhive-property-features',
599 'title' => __( 'Property Features', 'propertyhive' ),
600 'callback' => 'PH_Meta_Box_Property_Features::output',
601 'screen' => 'property',
602 'context' => 'normal',
603 'priority' => 'high'
604 );
605 $meta_boxes[10] = array(
606 'id' => 'postexcerpt',
607 'title' => __( 'Property Summary Description', 'propertyhive' ),
608 'callback' => 'PH_Meta_Box_Property_Summary_Description::output',
609 'screen' => 'property',
610 'context' => 'normal',
611 'priority' => 'high'
612 );
613 $meta_boxes[15] = array(
614 'id' => 'propertyhive-property-rooms',
615 'title' => __( 'Property Rooms', 'propertyhive' ),
616 'callback' => 'PH_Meta_Box_Property_Rooms::output',
617 'screen' => 'property',
618 'context' => 'normal',
619 'priority' => 'high'
620 );
621 $meta_boxes[20] = array(
622 'id' => 'propertyhive-property-description',
623 'title' => __( 'Property Description', 'propertyhive' ),
624 'callback' => 'PH_Meta_Box_Property_Description::output',
625 'screen' => 'property',
626 'context' => 'normal',
627 'priority' => 'high'
628 );
629
630 $meta_boxes = apply_filters( 'propertyhive_property_descriptions_meta_boxes', $meta_boxes );
631 ksort($meta_boxes);
632
633 $ids = array();
634 foreach ($meta_boxes as $meta_box)
635 {
636 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
637 $ids[] = $meta_box['id'];
638 }
639
640 $tabs['tab_descriptions'] = array(
641 'name' => __( 'Descriptions', 'propertyhive' ),
642 'metabox_ids' => $ids,
643 'post_type' => 'property'
644 );
645
646 /* PROPERTY MEDIA META BOXES */
647 $meta_boxes = array();
648 $meta_boxes[5] = array(
649 'id' => 'propertyhive-property-photos',
650 'title' => __( 'Property Photos', 'propertyhive' ),
651 'callback' => 'PH_Meta_Box_Property_Photos::output',
652 'screen' => 'property',
653 'context' => 'normal',
654 'priority' => 'high'
655 );
656 $meta_boxes[10] = array(
657 'id' => 'propertyhive-property-floorplans',
658 'title' => __( 'Property Floorplans', 'propertyhive' ),
659 'callback' => 'PH_Meta_Box_Property_Floorplans::output',
660 'screen' => 'property',
661 'context' => 'normal',
662 'priority' => 'high'
663 );
664 $meta_boxes[15] = array(
665 'id' => 'propertyhive-property-brochures',
666 'title' => __( 'Property Brochures', 'propertyhive' ),
667 'callback' => 'PH_Meta_Box_Property_Brochures::output',
668 'screen' => 'property',
669 'context' => 'normal',
670 'priority' => 'high'
671 );
672 $meta_boxes[20] = array(
673 'id' => 'propertyhive-property-epcs',
674 'title' => __( 'Property EPCs', 'propertyhive' ),
675 'callback' => 'PH_Meta_Box_Property_Epcs::output',
676 'screen' => 'property',
677 'context' => 'normal',
678 'priority' => 'high'
679 );
680 $meta_boxes[25] = array(
681 'id' => 'propertyhive-property-virtual-tours',
682 'title' => __( 'Property Virtual Tours', 'propertyhive' ),
683 'callback' => 'PH_Meta_Box_Property_Virtual_Tours::output',
684 'screen' => 'property',
685 'context' => 'normal',
686 'priority' => 'high'
687 );
688
689 $meta_boxes = apply_filters( 'propertyhive_property_media_meta_boxes', $meta_boxes );
690 ksort($meta_boxes);
691
692 $ids = array();
693 foreach ($meta_boxes as $meta_box)
694 {
695 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
696 $ids[] = $meta_box['id'];
697 }
698
699 $tabs['tab_media'] = array(
700 'name' => __( 'Media', 'propertyhive' ),
701 'metabox_ids' => $ids,
702 'post_type' => 'property'
703 );
704
705 if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'property' )
706 {
707 /* PROPERTY VIEWINGS META BOXES */
708 if ( get_option('propertyhive_module_disabled_viewings', '') != 'yes' )
709 {
710 $meta_boxes = array();
711 $meta_boxes[5] = array(
712 'id' => 'propertyhive-property-viewings',
713 'title' => __( 'Viewings', 'propertyhive' ),
714 'callback' => 'PH_Meta_Box_Property_Viewings::output',
715 'screen' => 'property',
716 'context' => 'normal',
717 'priority' => 'high'
718 );
719
720 $meta_boxes = apply_filters( 'propertyhive_property_viewings_meta_boxes', $meta_boxes );
721 ksort($meta_boxes);
722
723 $ids = array();
724 foreach ($meta_boxes as $meta_box)
725 {
726 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
727 $ids[] = $meta_box['id'];
728 }
729
730 $tabs['tab_viewings'] = array(
731 'name' => __( 'Viewings', 'propertyhive' ),
732 'metabox_ids' => $ids,
733 'post_type' => 'property',
734 'ajax_actions' => array( 'get_property_viewings_meta_box^' . wp_create_nonce( 'get_property_viewings_meta_box' ) ),
735 );
736 }
737
738 if ( get_option('propertyhive_module_disabled_offers_sales', '') != 'yes' )
739 {
740 if ( get_post_meta( $post->ID, '_department', TRUE ) == 'residential-sales' )
741 {
742 /* PROPERTY OFFERS META BOXES */
743 $meta_boxes = array();
744 $meta_boxes[5] = array(
745 'id' => 'propertyhive-property-offers',
746 'title' => __( 'Offers', 'propertyhive' ),
747 'callback' => 'PH_Meta_Box_Property_Offers::output',
748 'screen' => 'property',
749 'context' => 'normal',
750 'priority' => 'high'
751 );
752
753 $meta_boxes = apply_filters( 'propertyhive_property_offers_meta_boxes', $meta_boxes );
754 ksort($meta_boxes);
755
756 $ids = array();
757 foreach ($meta_boxes as $meta_box)
758 {
759 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
760 $ids[] = $meta_box['id'];
761 }
762
763 $tabs['tab_offers'] = array(
764 'name' => __( 'Offers', 'propertyhive' ),
765 'metabox_ids' => $ids,
766 'post_type' => 'property',
767 'ajax_actions' => array( 'get_property_offers_meta_box^' . wp_create_nonce( 'get_property_offers_meta_box' ) ),
768 );
769
770 /* PROPERTY SALES META BOXES */
771 $meta_boxes = array();
772 $meta_boxes[5] = array(
773 'id' => 'propertyhive-property-sales',
774 'title' => __( 'Sales', 'propertyhive' ),
775 'callback' => 'PH_Meta_Box_Property_Sales::output',
776 'screen' => 'property',
777 'context' => 'normal',
778 'priority' => 'high'
779 );
780
781 $meta_boxes = apply_filters( 'propertyhive_property_sales_meta_boxes', $meta_boxes );
782 ksort($meta_boxes);
783
784 $ids = array();
785 foreach ($meta_boxes as $meta_box)
786 {
787 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
788 $ids[] = $meta_box['id'];
789 }
790
791 $tabs['tab_sales'] = array(
792 'name' => __( 'Sales', 'propertyhive' ),
793 'metabox_ids' => $ids,
794 'post_type' => 'property',
795 'ajax_actions' => array( 'get_property_sales_meta_box^' . wp_create_nonce( 'get_property_sales_meta_box' ) ),
796 );
797 }
798 }
799 }
800
801 if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'property' )
802 {
803 if ( get_option('propertyhive_module_disabled_enquiries', '') != 'yes' )
804 {
805 /* PROPERTY ENQUIRIES META BOXES */
806 $meta_boxes = array();
807 $meta_boxes[5] = array(
808 'id' => 'propertyhive-property-enquiries',
809 'title' => __( 'Enquiries', 'propertyhive' ),
810 'callback' => 'PH_Meta_Box_Property_Enquiries::output',
811 'screen' => 'property',
812 'context' => 'normal',
813 'priority' => 'high'
814 );
815
816 $meta_boxes = apply_filters( 'propertyhive_property_enquiries_meta_boxes', $meta_boxes );
817 ksort($meta_boxes);
818
819 $ids = array();
820 foreach ($meta_boxes as $meta_box)
821 {
822 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
823 $ids[] = $meta_box['id'];
824 }
825
826 $tabs['tab_enquiries'] = array(
827 'name' => __( 'Enquiries', 'propertyhive' ),
828 'metabox_ids' => $ids,
829 'post_type' => 'property'
830 );
831 }
832 }
833
834 if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'property' )
835 {
836 /* PROPERTY NOTES META BOXES */
837 $meta_boxes = array();
838 $meta_boxes[5] = array(
839 'id' => 'propertyhive-property-history-notes',
840 'title' => __( 'Property History &amp; Notes', 'propertyhive' ),
841 'callback' => 'PH_Meta_Box_Property_Notes::output',
842 'screen' => 'property',
843 'context' => 'normal',
844 'priority' => 'high'
845 );
846
847 $meta_boxes = apply_filters( 'propertyhive_property_notes_meta_boxes', $meta_boxes );
848 ksort($meta_boxes);
849
850 $ids = array();
851 foreach ($meta_boxes as $meta_box)
852 {
853 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
854 $ids[] = $meta_box['id'];
855 }
856
857 $tabs['tab_notes'] = array(
858 'name' => __( 'History &amp; Notes', 'propertyhive' ),
859 'metabox_ids' => $ids,
860 'post_type' => 'property'
861 );
862
863 add_meta_box( 'propertyhive-property-actions', __( 'Actions', 'propertyhive' ), 'PH_Meta_Box_Property_Actions::output', 'property', 'side' );
864 }
865
866 // CONTACT
867 $meta_boxes = array();
868
869 if ( $pagenow == 'post-new.php' && get_post_type($post->ID) == 'contact' )
870 {
871 $meta_boxes[1] = array(
872 'id' => 'propertyhive-contact-new-relationship',
873 'title' => __( 'Contact Type', 'propertyhive' ),
874 'callback' => 'PH_Meta_Box_Contact_New_Relationship::output',
875 'screen' => 'contact',
876 'context' => 'normal',
877 'priority' => 'high'
878 );
879 }
880
881 $meta_boxes[5] = array(
882 'id' => 'propertyhive-contact-correspondence-address',
883 'title' => __( 'Correspondence Address', 'propertyhive' ),
884 'callback' => 'PH_Meta_Box_Contact_Correspondence_Address::output',
885 'screen' => 'contact',
886 'context' => 'normal',
887 'priority' => 'high'
888 );
889 $meta_boxes[10] = array(
890 'id' => 'propertyhive-contact-contact-details',
891 'title' => __( 'Contact Details', 'propertyhive' ),
892 'callback' => 'PH_Meta_Box_Contact_Contact_Details::output',
893 'screen' => 'contact',
894 'context' => 'normal',
895 'priority' => 'high'
896 );
897
898 $meta_boxes = apply_filters( 'propertyhive_contact_details_meta_boxes', $meta_boxes );
899 ksort($meta_boxes);
900
901 $ids = array();
902 foreach ($meta_boxes as $meta_box)
903 {
904 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
905 $ids[] = $meta_box['id'];
906 }
907
908 $tabs['tab_contact_details'] = array(
909 'name' => __( 'Contact Details', 'propertyhive' ),
910 'metabox_ids' => $ids,
911 'post_type' => 'contact'
912 );
913
914 if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'contact' )
915 {
916 add_meta_box( 'propertyhive-contact-relationships', __( 'Relationships', 'propertyhive' ), 'PH_Meta_Box_Contact_Relationships::output', 'contact', 'normal', 'high' );
917 $tabs['tab_contact_relationships'] = array(
918 'name' => __( 'Relationships', 'propertyhive' ),
919 'metabox_ids' => array('propertyhive-contact-relationships'),
920 'post_type' => 'contact'
921 );
922 }
923
924 if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'contact' )
925 {
926 $show_viewings = false;
927 $show_offers = false;
928 $show_sales = false;
929
930 $contact_types = get_post_meta( $post->ID, '_contact_types', TRUE );
931 if ( is_array($contact_types) && in_array('applicant', $contact_types) )
932 {
933 $show_viewings = true;
934
935 $num_applicant_profiles = get_post_meta( $post->ID, '_applicant_profiles', TRUE );
936 if ( $num_applicant_profiles == '' )
937 {
938 $num_applicant_profiles = 0;
939 }
940
941 if ( $num_applicant_profiles > 0 )
942 {
943 for ( $i = 0; $i < $num_applicant_profiles; ++$i )
944 {
945 $applicant_profile = get_post_meta( $post->ID, '_applicant_profile_' . $i, TRUE );
946
947 if ( isset($applicant_profile['department']) && $applicant_profile['department'] == 'residential-sales' )
948 {
949 $show_offers = true;
950 $show_sales = true;
951 }
952 }
953 }
954 }
955 else
956 {
957 $args = array(
958 'post_type' => 'viewing',
959 'posts_per_page' => 1,
960 'fields' => 'ids',
961 'meta_query' => array(
962 array(
963 'key' => '_applicant_contact_id',
964 'value' => $post->ID
965 )
966 )
967 );
968 $viewing_query = new WP_Query( $args );
969 if ($viewing_query->have_posts())
970 {
971 $show_viewings = true;
972 }
973 wp_reset_postdata();
974
975 $args = array(
976 'post_type' => 'offer',
977 'posts_per_page' => 1,
978 'fields' => 'ids',
979 'meta_query' => array(
980 array(
981 'key' => '_applicant_contact_id',
982 'value' => $post->ID
983 )
984 )
985 );
986 $offer_query = new WP_Query( $args );
987 if ($offer_query->have_posts())
988 {
989 $show_offers = true;
990 }
991 wp_reset_postdata();
992
993 $args = array(
994 'post_type' => 'sale',
995 'posts_per_page' => 1,
996 'fields' => 'ids',
997 'meta_query' => array(
998 array(
999 'key' => '_applicant_contact_id',
1000 'value' => $post->ID
1001 )
1002 )
1003 );
1004 $sale_query = new WP_Query( $args );
1005 if ($sale_query->have_posts())
1006 {
1007 $show_sales = true;
1008 }
1009 wp_reset_postdata();
1010 }
1011
1012 if ( get_option('propertyhive_module_disabled_viewings', '') != 'yes' )
1013 {
1014 if ( $show_viewings )
1015 {
1016 /* CONTACT VIEWINGS META BOXES */
1017 add_meta_box( 'propertyhive-contact-viewings', __( 'Viewings', 'propertyhive' ), 'PH_Meta_Box_Contact_Viewings::output', 'contact', 'normal', 'high' );
1018
1019 $tabs['tab_viewings'] = array(
1020 'name' => __( 'Viewings', 'propertyhive' ),
1021 'metabox_ids' => array('propertyhive-contact-viewings'),
1022 'post_type' => 'contact',
1023 'ajax_actions' => array( 'get_contact_viewings_meta_box^' . wp_create_nonce( 'get_contact_viewings_meta_box' ) ),
1024 );
1025 }
1026 }
1027
1028 if ( get_option('propertyhive_module_disabled_offers_sales', '') != 'yes' )
1029 {
1030 if ( $show_offers )
1031 {
1032 /* CONTACT OFFERS META BOXES */
1033 add_meta_box( 'propertyhive-contact-offers', __( 'Offers', 'propertyhive' ), 'PH_Meta_Box_Contact_Offers::output', 'contact', 'normal', 'high' );
1034
1035 $tabs['tab_offers'] = array(
1036 'name' => __( 'Offers', 'propertyhive' ),
1037 'metabox_ids' => array('propertyhive-contact-offers'),
1038 'post_type' => 'contact',
1039 'ajax_actions' => array( 'get_contact_offers_meta_box^' . wp_create_nonce( 'get_contact_offers_meta_box' ) ),
1040 );
1041 }
1042
1043 if ( $show_sales )
1044 {
1045 /* CONTACT SALES META BOXES */
1046 add_meta_box( 'propertyhive-contact-sales', __( 'Sales', 'propertyhive' ), 'PH_Meta_Box_Contact_Sales::output', 'contact', 'normal', 'high' );
1047
1048 $tabs['tab_sales'] = array(
1049 'name' => __( 'Sales', 'propertyhive' ),
1050 'metabox_ids' => array('propertyhive-contact-sales'),
1051 'post_type' => 'contact',
1052 'ajax_actions' => array( 'get_contact_sales_meta_box^' . wp_create_nonce( 'get_contact_sales_meta_box' ) ),
1053 );
1054 }
1055 }
1056 $meta_boxes = array();
1057 $meta_boxes[5] = array(
1058 'id' => 'propertyhive-contact-history-notes',
1059 'title' => __( 'Contact History &amp; Notes', 'propertyhive' ),
1060 'callback' => 'PH_Meta_Box_Contact_Notes::output',
1061 'screen' => 'contact',
1062 'context' => 'normal',
1063 'priority' => 'high'
1064 );
1065
1066 $meta_boxes = apply_filters( 'propertyhive_contact_notes_meta_boxes', $meta_boxes );
1067 ksort($meta_boxes);
1068
1069 $ids = array();
1070 foreach ($meta_boxes as $meta_box)
1071 {
1072 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
1073 $ids[] = $meta_box['id'];
1074 }
1075
1076 $tabs['tab_notes'] = array(
1077 'name' => __( 'History &amp; Notes', 'propertyhive' ),
1078 'metabox_ids' => $ids,
1079 'post_type' => 'contact'
1080 );
1081
1082 add_meta_box( 'propertyhive-contact-actions', __( 'Actions', 'propertyhive' ), 'PH_Meta_Box_Contact_Actions::output', 'contact', 'side' );
1083 }
1084
1085 // ENQUIRY
1086 add_meta_box( 'propertyhive-enquiry-record-details', __( 'Record Details', 'propertyhive' ), 'PH_Meta_Box_Enquiry_Record_details::output', 'enquiry', 'normal', 'high' );
1087 add_meta_box( 'propertyhive-enquiry-details', __( 'Enquiry Details', 'propertyhive' ), 'PH_Meta_Box_Enquiry_details::output', 'enquiry', 'normal', 'high' );
1088 $tabs['tab_enquiry_details'] = array(
1089 'name' => __( 'Details', 'propertyhive' ),
1090 'metabox_ids' => array('propertyhive-enquiry-record-details', 'propertyhive-enquiry-details'),
1091 'post_type' => 'enquiry'
1092 );
1093
1094 if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'enquiry' )
1095 {
1096 $meta_boxes = array();
1097 $meta_boxes[5] = array(
1098 'id' => 'propertyhive-enquiry-history-notes',
1099 'title' => __( 'Enquiry History &amp; Notes', 'propertyhive' ),
1100 'callback' => 'PH_Meta_Box_Enquiry_Notes::output',
1101 'screen' => 'enquiry',
1102 'context' => 'normal',
1103 'priority' => 'high'
1104 );
1105
1106 $meta_boxes = apply_filters( 'propertyhive_enquiry_notes_meta_boxes', $meta_boxes );
1107 ksort($meta_boxes);
1108
1109 $ids = array();
1110 foreach ($meta_boxes as $meta_box)
1111 {
1112 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
1113 $ids[] = $meta_box['id'];
1114 }
1115
1116 $tabs['tab_notes'] = array(
1117 'name' => __( 'History &amp; Notes', 'propertyhive' ),
1118 'metabox_ids' => $ids,
1119 'post_type' => 'enquiry'
1120 );
1121 }
1122
1123 // APPRAISAL
1124 if (!isset($tabs)) $tabs = array();
1125
1126 /* APPRAISAL SUMMARY META BOXES */
1127 $meta_boxes = array();
1128 if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'appraisal' )
1129 {
1130 $meta_boxes[5] = array(
1131 'id' => 'propertyhive-appraisal-details',
1132 'title' => __( 'Appraisal Details', 'propertyhive' ),
1133 'callback' => 'PH_Meta_Box_Appraisal_Details::output',
1134 'screen' => 'appraisal',
1135 'context' => 'normal',
1136 'priority' => 'high'
1137 );
1138 }
1139 $meta_boxes[10] = array(
1140 'id' => 'propertyhive-appraisal-event',
1141 'title' => __( 'Event Details', 'propertyhive' ),
1142 'callback' => 'PH_Meta_Box_Appraisal_Event::output',
1143 'screen' => 'appraisal',
1144 'context' => 'normal',
1145 'priority' => 'high'
1146 );
1147 $meta_boxes[15] = array(
1148 'id' => 'propertyhive-appraisal-property-owner',
1149 'title' => __( 'Property Owner Details', 'propertyhive' ),
1150 'callback' => 'PH_Meta_Box_Appraisal_Property_Owner::output',
1151 'screen' => 'appraisal',
1152 'context' => 'normal',
1153 'priority' => 'high'
1154 );
1155 $meta_boxes[20] = array(
1156 'id' => 'propertyhive-appraisal-property',
1157 'title' => __( 'Property Details', 'propertyhive' ),
1158 'callback' => 'PH_Meta_Box_Appraisal_Property::output',
1159 'screen' => 'appraisal',
1160 'context' => 'normal',
1161 'priority' => 'high'
1162 );
1163
1164 $meta_boxes = apply_filters( 'propertyhive_appraisal_summary_meta_boxes', $meta_boxes );
1165 ksort($meta_boxes);
1166
1167 $ids = array();
1168 foreach ($meta_boxes as $meta_box)
1169 {
1170 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
1171 $ids[] = $meta_box['id'];
1172 }
1173
1174 $tabs['tab_appraisal_summary'] = array(
1175 'name' => __( 'Summary', 'propertyhive' ),
1176 'metabox_ids' => $ids,
1177 'post_type' => 'appraisal'
1178 );
1179
1180 if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'appraisal' )
1181 {
1182 $meta_boxes = array();
1183 $meta_boxes[5] = array(
1184 'id' => 'propertyhive-appraisal-history-notes',
1185 'title' => __( 'Appraisal History &amp; Notes', 'propertyhive' ),
1186 'callback' => 'PH_Meta_Box_Appraisal_Notes::output',
1187 'screen' => 'appraisal',
1188 'context' => 'normal',
1189 'priority' => 'high'
1190 );
1191
1192 $meta_boxes = apply_filters( 'propertyhive_appraisal_notes_meta_boxes', $meta_boxes );
1193 ksort($meta_boxes);
1194
1195 $ids = array();
1196 foreach ($meta_boxes as $meta_box)
1197 {
1198 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
1199 $ids[] = $meta_box['id'];
1200 }
1201
1202 $tabs['tab_notes'] = array(
1203 'name' => __( 'History &amp; Notes', 'propertyhive' ),
1204 'metabox_ids' => $ids,
1205 'post_type' => 'appraisal'
1206 );
1207
1208 add_meta_box( 'propertyhive-appraisal-actions', __( 'Actions', 'propertyhive' ), 'PH_Meta_Box_Appraisal_Actions::output', 'appraisal', 'side' );
1209 }
1210
1211 // VIEWING
1212 if (!isset($tabs)) $tabs = array();
1213
1214 /* VIEWING SUMMARY META BOXES */
1215 $meta_boxes = array();
1216 if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'viewing' )
1217 {
1218 $meta_boxes[5] = array(
1219 'id' => 'propertyhive-viewing-details',
1220 'title' => __( 'Viewing Details', 'propertyhive' ),
1221 'callback' => 'PH_Meta_Box_Viewing_Details::output',
1222 'screen' => 'viewing',
1223 'context' => 'normal',
1224 'priority' => 'high'
1225 );
1226 }
1227 $meta_boxes[10] = array(
1228 'id' => 'propertyhive-viewing-event',
1229 'title' => __( 'Event Details', 'propertyhive' ),
1230 'callback' => 'PH_Meta_Box_Viewing_Event::output',
1231 'screen' => 'viewing',
1232 'context' => 'normal',
1233 'priority' => 'high'
1234 );
1235 $meta_boxes[15] = array(
1236 'id' => 'propertyhive-viewing-applicant',
1237 'title' => __( 'Applicant Details', 'propertyhive' ),
1238 'callback' => 'PH_Meta_Box_Viewing_Applicant::output',
1239 'screen' => 'viewing',
1240 'context' => 'normal',
1241 'priority' => 'high'
1242 );
1243 $meta_boxes[20] = array(
1244 'id' => 'propertyhive-viewing-property',
1245 'title' => __( 'Property Details', 'propertyhive' ),
1246 'callback' => 'PH_Meta_Box_Viewing_Property::output',
1247 'screen' => 'viewing',
1248 'context' => 'normal',
1249 'priority' => 'high'
1250 );
1251
1252 $meta_boxes = apply_filters( 'propertyhive_viewing_summary_meta_boxes', $meta_boxes );
1253 ksort($meta_boxes);
1254
1255 $ids = array();
1256 foreach ($meta_boxes as $meta_box)
1257 {
1258 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
1259 $ids[] = $meta_box['id'];
1260 }
1261
1262 $tabs['tab_viewing_summary'] = array(
1263 'name' => __( 'Summary', 'propertyhive' ),
1264 'metabox_ids' => $ids,
1265 'post_type' => 'viewing'
1266 );
1267
1268 if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'viewing' )
1269 {
1270 $meta_boxes = array();
1271 $meta_boxes[5] = array(
1272 'id' => 'propertyhive-viewing-history-notes',
1273 'title' => __( 'Viewing History &amp; Notes', 'propertyhive' ),
1274 'callback' => 'PH_Meta_Box_Viewing_Notes::output',
1275 'screen' => 'viewing',
1276 'context' => 'normal',
1277 'priority' => 'high'
1278 );
1279
1280 $meta_boxes = apply_filters( 'propertyhive_viewing_notes_meta_boxes', $meta_boxes );
1281 ksort($meta_boxes);
1282
1283 $ids = array();
1284 foreach ($meta_boxes as $meta_box)
1285 {
1286 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
1287 $ids[] = $meta_box['id'];
1288 }
1289
1290 $tabs['tab_notes'] = array(
1291 'name' => __( 'History &amp; Notes', 'propertyhive' ),
1292 'metabox_ids' => $ids,
1293 'post_type' => 'viewing'
1294 );
1295
1296 add_meta_box( 'propertyhive-viewing-actions', __( 'Actions', 'propertyhive' ), 'PH_Meta_Box_Viewing_Actions::output', 'viewing', 'side' );
1297 }
1298
1299 // OFFER
1300 if (!isset($tabs)) $tabs = array();
1301
1302 /* OFFER SUMMARY META BOXES */
1303 $meta_boxes = array();
1304 $meta_boxes[5] = array(
1305 'id' => 'propertyhive-offer-details',
1306 'title' => __( 'Offer Details', 'propertyhive' ),
1307 'callback' => 'PH_Meta_Box_Offer_Details::output',
1308 'screen' => 'offer',
1309 'context' => 'normal',
1310 'priority' => 'high'
1311 );
1312 $meta_boxes[10] = array(
1313 'id' => 'propertyhive-offer-property',
1314 'title' => __( 'Property Details', 'propertyhive' ),
1315 'callback' => 'PH_Meta_Box_Offer_Property::output',
1316 'screen' => 'offer',
1317 'context' => 'normal',
1318 'priority' => 'high'
1319 );
1320 $meta_boxes[15] = array(
1321 'id' => 'propertyhive-offer-property-owner-solicitor',
1322 'title' => __( 'Property Owner Solicitor Details', 'propertyhive' ),
1323 'callback' => 'PH_Meta_Box_Offer_Property_Owner_Solicitor::output',
1324 'screen' => 'offer',
1325 'context' => 'normal',
1326 'priority' => 'high'
1327 );
1328 $meta_boxes[20] = array(
1329 'id' => 'propertyhive-offer-applicant',
1330 'title' => __( 'Applicant Details', 'propertyhive' ),
1331 'callback' => 'PH_Meta_Box_Offer_Applicant::output',
1332 'screen' => 'offer',
1333 'context' => 'normal',
1334 'priority' => 'high'
1335 );
1336 $meta_boxes[25] = array(
1337 'id' => 'propertyhive-offer-applicant-solicitor',
1338 'title' => __( 'Applicant Solicitor Details', 'propertyhive' ),
1339 'callback' => 'PH_Meta_Box_Offer_Applicant_Solicitor::output',
1340 'screen' => 'offer',
1341 'context' => 'normal',
1342 'priority' => 'high'
1343 );
1344
1345
1346 $meta_boxes = apply_filters( 'propertyhive_offer_summary_meta_boxes', $meta_boxes );
1347 ksort($meta_boxes);
1348
1349 $ids = array();
1350 foreach ($meta_boxes as $meta_box)
1351 {
1352 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
1353 $ids[] = $meta_box['id'];
1354 }
1355
1356 $tabs['tab_offer_summary'] = array(
1357 'name' => __( 'Summary', 'propertyhive' ),
1358 'metabox_ids' => $ids,
1359 'post_type' => 'offer'
1360 );
1361
1362 if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'offer' )
1363 {
1364 $meta_boxes = array();
1365 $meta_boxes[5] = array(
1366 'id' => 'propertyhive-offer-history-notes',
1367 'title' => __( 'Offer History &amp; Notes', 'propertyhive' ),
1368 'callback' => 'PH_Meta_Box_Offer_Notes::output',
1369 'screen' => 'offer',
1370 'context' => 'normal',
1371 'priority' => 'high'
1372 );
1373
1374 $meta_boxes = apply_filters( 'propertyhive_offer_notes_meta_boxes', $meta_boxes );
1375 ksort($meta_boxes);
1376
1377 $ids = array();
1378 foreach ($meta_boxes as $meta_box)
1379 {
1380 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
1381 $ids[] = $meta_box['id'];
1382 }
1383
1384 $tabs['tab_notes'] = array(
1385 'name' => __( 'History &amp; Notes', 'propertyhive' ),
1386 'metabox_ids' => $ids,
1387 'post_type' => 'offer'
1388 );
1389
1390 add_meta_box( 'propertyhive-offer-actions', __( 'Actions', 'propertyhive' ), 'PH_Meta_Box_Offer_Actions::output', 'offer', 'side' );
1391 }
1392
1393 // SALE
1394 if (!isset($tabs)) $tabs = array();
1395
1396 /* SALE SUMMARY META BOXES */
1397 $meta_boxes = array();
1398 $meta_boxes[5] = array(
1399 'id' => 'propertyhive-sale-details',
1400 'title' => __( 'Sale Details', 'propertyhive' ),
1401 'callback' => 'PH_Meta_Box_Sale_Details::output',
1402 'screen' => 'sale',
1403 'context' => 'normal',
1404 'priority' => 'high'
1405 );
1406 $meta_boxes[10] = array(
1407 'id' => 'propertyhive-sale-property',
1408 'title' => __( 'Property Details', 'propertyhive' ),
1409 'callback' => 'PH_Meta_Box_Sale_Property::output',
1410 'screen' => 'sale',
1411 'context' => 'normal',
1412 'priority' => 'high'
1413 );
1414 $meta_boxes[15] = array(
1415 'id' => 'propertyhive-sale-property-owner-solicitor',
1416 'title' => __( 'Property Owner Solicitor Details', 'propertyhive' ),
1417 'callback' => 'PH_Meta_Box_Sale_Property_Owner_Solicitor::output',
1418 'screen' => 'sale',
1419 'context' => 'normal',
1420 'priority' => 'high'
1421 );
1422 $meta_boxes[20] = array(
1423 'id' => 'propertyhive-sale-applicant',
1424 'title' => __( 'Applicant Details', 'propertyhive' ),
1425 'callback' => 'PH_Meta_Box_Sale_Applicant::output',
1426 'screen' => 'sale',
1427 'context' => 'normal',
1428 'priority' => 'high'
1429 );
1430 $meta_boxes[25] = array(
1431 'id' => 'propertyhive-sale-applicant-solicitor',
1432 'title' => __( 'Applicant Solicitor Details', 'propertyhive' ),
1433 'callback' => 'PH_Meta_Box_Sale_Applicant_Solicitor::output',
1434 'screen' => 'sale',
1435 'context' => 'normal',
1436 'priority' => 'high'
1437 );
1438
1439
1440 $meta_boxes = apply_filters( 'propertyhive_offer_summary_meta_boxes', $meta_boxes );
1441 ksort($meta_boxes);
1442
1443 $ids = array();
1444 foreach ($meta_boxes as $meta_box)
1445 {
1446 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
1447 $ids[] = $meta_box['id'];
1448 }
1449
1450 $tabs['tab_sale_summary'] = array(
1451 'name' => __( 'Summary', 'propertyhive' ),
1452 'metabox_ids' => $ids,
1453 'post_type' => 'sale'
1454 );
1455
1456 if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'sale' )
1457 {
1458 $meta_boxes = array();
1459 $meta_boxes[5] = array(
1460 'id' => 'propertyhive-sale-history-notes',
1461 'title' => __( 'Sale History &amp; Notes', 'propertyhive' ),
1462 'callback' => 'PH_Meta_Box_Sale_Notes::output',
1463 'screen' => 'sale',
1464 'context' => 'normal',
1465 'priority' => 'high'
1466 );
1467
1468 $meta_boxes = apply_filters( 'propertyhive_sale_notes_meta_boxes', $meta_boxes );
1469 ksort($meta_boxes);
1470
1471 $ids = array();
1472 foreach ($meta_boxes as $meta_box)
1473 {
1474 add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] );
1475 $ids[] = $meta_box['id'];
1476 }
1477
1478 $tabs['tab_notes'] = array(
1479 'name' => __( 'History &amp; Notes', 'propertyhive' ),
1480 'metabox_ids' => $ids,
1481 'post_type' => 'sale'
1482 );
1483
1484 add_meta_box( 'propertyhive-sale-actions', __( 'Actions', 'propertyhive' ), 'PH_Meta_Box_Sale_Actions::output', 'sale', 'side' );
1485 }
1486
1487 $tabs = apply_filters( 'propertyhive_tabs', $tabs );
1488
1489 // Force order of meta boxes
1490 $meta_box_ids = array();
1491 if (
1492 in_array(
1493 get_post_type($post->ID),
1494 apply_filters( 'propertyhive_post_types_with_tabs', array('property', 'contact', 'enquiry', 'viewing', 'offer', 'sale') )
1495 )
1496 )
1497 {
1498 foreach ( $tabs as $tab_id => $tab_options)
1499 {
1500 if ( isset($tab_options['post_type']) && $tab_options['post_type'] == get_post_type($post->ID) )
1501 {
1502 $meta_box_ids = array_merge( $meta_box_ids, $tab_options['metabox_ids'] );
1503 }
1504 }
1505 }
1506
1507 if (!empty($meta_box_ids) )
1508 {
1509 $existing_meta_box_order = get_user_meta( get_current_user_id(), 'meta-box-order_' . get_post_type($post->ID), TRUE );
1510 if ( $existing_meta_box_order == '' )
1511 {
1512 $existing_meta_box_order = array();
1513 $existing_meta_box_order['side'] = '';
1514 $existing_meta_box_order['advanced'] = '';
1515 }
1516 $existing_meta_box_order['normal'] = implode(",", $meta_box_ids);
1517
1518 update_user_meta( get_current_user_id(), 'meta-box-order_' . get_post_type($post->ID), $existing_meta_box_order );
1519 }
1520
1521 // TO DO: move this so it works when in one column
1522 add_action( 'edit_form_after_title', array( $this, 'draw_meta_box_tabs' ), 31, 1);
1523 }
1524
1525 /**
1526 * Draw meta box tabs
1527 */
1528 public function draw_meta_box_tabs() {
1529
1530 global $post, $tabs;
1531
1532 if (
1533 !empty($tabs) &&
1534 in_array(
1535 $post->post_type,
1536 apply_filters( 'propertyhive_post_types_with_tabs', array('property', 'contact', 'enquiry', 'appraisal', 'viewing', 'offer', 'sale') )
1537 )
1538 )
1539 {
1540 $meta_boxes_under_tabs = array();
1541
1542 $i = 0;
1543 echo '<div id="propertyhive_metabox_tabs" style="margin-top:15px">';
1544 foreach ($tabs as $tab_id => $tab)
1545 {
1546 if (isset($tab['post_type']) && $post->post_type == $tab['post_type'])
1547 {
1548 echo '<a href="#' . implode("|#", $tab['metabox_ids']) . '" id="' . $tab_id . '" class="button' . ( ($i == 0) ? ' button-primary' : '') . '"';
1549 if ( isset($tab['ajax_actions']) )
1550 {
1551 echo ' data-ajax-actions="' . implode("|", $tab['ajax_actions']) . '"';
1552 }
1553 echo '>' . $tab['name'] . '</a> ';
1554
1555 $meta_boxes_under_tabs[] = $tab['metabox_ids'];
1556
1557 ++$i;
1558 }
1559 }
1560 echo '</div><br>';
1561
1562 // hidden field to keep track of selected hash
1563 echo '<input type="hidden" name="propertyhive_selected_metabox_tab" id="propertyhive_selected_metabox_tab" value="">';
1564
1565 if (!empty($meta_boxes_under_tabs))
1566 {
1567 echo '
1568 <script>
1569 var meta_boxes_under_tabs = ' . json_encode($meta_boxes_under_tabs) . ';
1570
1571 var ajax_actions_executed = new Array();
1572
1573 jQuery(document).ready(function()
1574 {
1575 // Hide all on page load
1576 hide_meta_box_tabs();
1577
1578 // Show first meta box
1579 //jQuery(\'#\' + meta_boxes_under_tabs[0][0] + \'\').show();
1580 for (var i in meta_boxes_under_tabs[0])
1581 {
1582 jQuery(\'#\' + meta_boxes_under_tabs[0][i] + \'\').show();
1583 }
1584 //jQuery(\'#propertyhive_metabox_tabs a:first-child\').trigger(\'click\');
1585
1586 // Set first button as primary
1587 jQuery(\'#propertyhive_metabox_tabs a:first-child\').addClass(\'button-primary\');
1588
1589 // Hide meta boxes and show correct one when tab clicked
1590 jQuery(\'#propertyhive_metabox_tabs a\').click(function(e)
1591 {
1592 e.preventDefault();
1593
1594 hide_meta_box_tabs();
1595
1596 var this_href = jQuery(this).attr(\'href\').split(\'|\');
1597
1598 for (var i in this_href)
1599 {
1600 jQuery(this_href[i]).show();
1601 }
1602
1603 jQuery(this).addClass(\'button-primary\');
1604
1605 ' . ( ( $post->post_type == 'property' ) ? 'if (jQuery(this).attr(\'id\') == \'tab_details\') { showHideDepartmentMetaBox(); }' : '' ) . '
1606 ' . ( ( $post->post_type == 'property' ) ? 'if (jQuery(this).attr(\'id\') == \'tab_descriptions\') { showHideRoomsMetaBox(); }' : '' ) . '
1607 ' . ( ( $post->post_type == 'property' ) ? 'if (jQuery(this).attr(\'id\') == \'tab_descriptions\') { showHideDescriptionsMetaBox(); }' : '' ) . '
1608
1609 if ( jQuery(this).attr(\'data-ajax-actions\') && jQuery(this).attr(\'data-ajax-actions\') != \'\' )
1610 {
1611 var ajax_actions = jQuery(this).attr(\'data-ajax-actions\').split(\'|\');
1612
1613 for ( var i in ajax_actions )
1614 {
1615 var ajax_action = ajax_actions[i].split(\'^\');
1616
1617 jQuery(\'#\' + ajax_action[0].replace(\'get_\', \'propertyhive_\')).html(\'Loading...\');
1618
1619 //if () // only do action once
1620 //{
1621 var data = {
1622 action: \'propertyhive_\' + ajax_action[0],
1623 post_id: ' . $post->ID . ',
1624 security: ajax_action[1]
1625 }
1626
1627 jQuery.post( \'' . admin_url('admin-ajax.php') . '\', data, function(response)
1628 {
1629 jQuery(\'#\' + ajax_action[0].replace(\'get_\', \'propertyhive_\')).html(response);
1630 activateTipTip();
1631 }, \'html\');
1632 //}
1633 }
1634 }
1635
1636 //window.location.hash = jQuery(this).attr(\'href\');
1637 history.pushState({}, \'\', \'#\' + jQuery(this).attr(\'href\').replace(/#/g, \'\').replace(/\|/g, \'%7C\'));
1638
1639 jQuery(\'#propertyhive_selected_metabox_tab\').val(jQuery(this).attr(\'href\').replace(/#/g, \'\').replace(/\|/g, \'%7C\'));
1640
1641 return false;
1642 });
1643
1644 // Set default tab if hash set
1645 if (window.location.hash != \'\')
1646 {
1647 var hash = window.location.hash;
1648 if ( window.location.hash.indexOf(\'%7C\') )
1649 {
1650 hash = window.location.hash.replace(/%7C/g, \'|#\');
1651 }
1652 jQuery("#propertyhive_metabox_tabs a[href=\'" + hash + "\']").trigger(\'click\');
1653 }
1654 });
1655
1656 function hide_meta_box_tabs()
1657 {
1658 for (var i in meta_boxes_under_tabs)
1659 {
1660 for (var j in meta_boxes_under_tabs[i])
1661 {
1662 jQuery(\'#\' + meta_boxes_under_tabs[i][j] + \'\').hide();
1663 }
1664 }
1665
1666 jQuery(\'#propertyhive_metabox_tabs a\').removeClass(\'button-primary\');
1667 }
1668 </script>
1669 ';
1670 }
1671 }
1672
1673 }
1674
1675 /**
1676 * Remove bloat
1677 */
1678 public function remove_meta_boxes() {
1679 //remove_meta_box( 'submitdiv', 'property', 'side' );
1680 remove_meta_box( 'postexcerpt', 'property', 'normal' );
1681 remove_meta_box( 'pageparentdiv', 'property', 'side' );
1682 remove_meta_box( 'commentstatusdiv', 'property', 'normal' );
1683 remove_meta_box( 'commentstatusdiv', 'property', 'side' );
1684 remove_meta_box( 'commentsdiv', 'product', 'normal' );
1685 }
1686
1687 /**
1688 * Rename core meta boxes
1689 */
1690 public function rename_meta_boxes() {
1691 global $post;
1692
1693 // Comments/Reviews
1694 if ( isset( $post ) && ( 'publish' == $post->post_status || 'private' == $post->post_status ) ) {
1695 //remove_meta_box( 'commentsdiv', 'product', 'normal' );
1696
1697 //add_meta_box( 'commentsdiv', __( 'Reviews', 'propertyhive' ), 'post_comment_meta_box', 'product', 'normal' );
1698 }
1699 }
1700
1701 /**
1702 * Check if we're saving, then trigger an action based on the post type
1703 *
1704 * @param int $post_id
1705 * @param object $post
1706 */
1707 public function save_meta_boxes( $post_id, $post ) {
1708 // $post_id and $post are required
1709 if ( empty( $post_id ) || empty( $post ) ) {
1710 return;
1711 }
1712
1713 // Dont' save meta boxes for revisions or autosaves
1714 if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
1715 return;
1716 }
1717
1718 // Check the nonce
1719 if ( empty( $_POST['propertyhive_meta_nonce'] ) || ! wp_verify_nonce( $_POST['propertyhive_meta_nonce'], 'propertyhive_save_data' ) ) {
1720 return;
1721 }
1722
1723 // Check the post being saved == the $post_id to prevent triggering this call for other save_post events
1724 if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) {
1725 return;
1726 }
1727
1728 // Check user has permission to edit
1729 if ( ! current_user_can( 'edit_post', $post_id ) ) {
1730 return;
1731 }
1732
1733 // Check the post type
1734 if (
1735 ! in_array(
1736 $post->post_type,
1737 apply_filters( 'propertyhive_post_types_with_tabs', array('property', 'contact', 'enquiry', 'appraisal', 'viewing', 'offer', 'sale') )
1738 )
1739 ) {
1740 return;
1741 }
1742
1743 if ( isset($_POST['post_parent']) && $_POST['post_parent'] != '' && $_POST['post_parent'] != '0' )
1744 {
1745 global $wpdb;
1746
1747 $wpdb->update( $wpdb->posts, array( 'post_parent' => (int)$_POST['post_parent'] ), array( 'ID' => $post_id ) );
1748 }
1749
1750 do_action( 'propertyhive_process_' . $post->post_type . '_meta', $post_id, $post );
1751 }
1752
1753 }
1754
1755 new PH_Admin_Meta_Boxes();
1756
1757 }