| 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 |
add_action( 'post_submitbox_start', array( $this, 'add_archive_link_to_post_submitbox' ) ); |
| 36 |
|
| 37 |
// Save Property Meta Boxes |
| 38 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Address::save', 10, 2 ); |
| 39 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Owner::save', 12, 2 ); |
| 40 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Record_Details::save', 13, 2 ); |
| 41 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Coordinates::save', 70, 2 ); |
| 42 |
|
| 43 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Department::save', 15, 2 ); |
| 44 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Residential_Details::save', 20, 2 ); |
| 45 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Residential_Lettings_Details::save', 25, 2 ); |
| 46 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Residential_Sales_Details::save', 30, 2 ); |
| 47 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Commercial_Details::save', 30, 2 ); |
| 48 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Material_Information::save', 32, 2 ); |
| 49 |
|
| 50 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Marketing::save', 35, 2 ); |
| 51 |
|
| 52 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Rooms::save', 40, 2 ); |
| 53 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Features::save', 45, 2 ); |
| 54 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Description::save', 45, 2 ); |
| 55 |
|
| 56 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Photos::save', 50, 2 ); |
| 57 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Floorplans::save', 55, 2 ); |
| 58 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Brochures::save', 65, 2 ); |
| 59 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Epcs::save', 70, 2 ); |
| 60 |
add_action( 'propertyhive_process_property_meta', 'PH_Meta_Box_Property_Virtual_Tours::save', 75, 2 ); |
| 61 |
|
| 62 |
// Save Contact Meta Boxes |
| 63 |
if ( isset($_POST['_contact_type_new']) ) |
| 64 |
{ |
| 65 |
add_action( 'propertyhive_process_contact_meta', 'PH_Meta_Box_Contact_New_Relationship::save', 1, 2 ); |
| 66 |
} |
| 67 |
add_action( 'propertyhive_process_contact_meta', 'PH_Meta_Box_Contact_Correspondence_Address::save', 10, 2 ); |
| 68 |
add_action( 'propertyhive_process_contact_meta', 'PH_Meta_Box_Contact_Contact_Details::save', 15, 2 ); |
| 69 |
add_action( 'propertyhive_process_contact_meta', 'PH_Meta_Box_Contact_Solicitor::save', 20, 2 ); |
| 70 |
if ( !isset($_POST['_contact_type_new']) ) |
| 71 |
{ |
| 72 |
add_action( 'propertyhive_process_contact_meta', 'PH_Meta_Box_Contact_Relationships::save', 25, 2 ); |
| 73 |
} |
| 74 |
|
| 75 |
// Save Enquiry Meta Boxes |
| 76 |
if ( get_option('propertyhive_module_disabled_enquiries', '') != 'yes' ) |
| 77 |
{ |
| 78 |
add_action( 'propertyhive_process_enquiry_meta', 'PH_Meta_Box_Enquiry_Record_Details::save', 10, 2 ); |
| 79 |
add_action( 'propertyhive_process_enquiry_meta', 'PH_Meta_Box_Enquiry_Details::save', 15, 2 ); |
| 80 |
} |
| 81 |
|
| 82 |
// Save Appraisal Meta Boxes |
| 83 |
add_action( 'propertyhive_process_appraisal_meta', 'PH_Meta_Box_Appraisal_Details::save', 10, 2 ); |
| 84 |
add_action( 'propertyhive_process_appraisal_meta', 'PH_Meta_Box_Appraisal_Event::save', 15, 2 ); |
| 85 |
add_action( 'propertyhive_process_appraisal_meta', 'PH_Meta_Box_Appraisal_Property_Owner::save', 20, 2 ); |
| 86 |
add_action( 'propertyhive_process_appraisal_meta', 'PH_Meta_Box_Appraisal_Property::save', 25, 2 ); |
| 87 |
|
| 88 |
// Save Viewing Meta Boxes |
| 89 |
add_action( 'propertyhive_process_viewing_meta', 'PH_Meta_Box_Viewing_Details::save', 10, 2 ); |
| 90 |
add_action( 'propertyhive_process_viewing_meta', 'PH_Meta_Box_Viewing_Event::save', 15, 2 ); |
| 91 |
add_action( 'propertyhive_process_viewing_meta', 'PH_Meta_Box_Viewing_Applicant::save', 20, 2 ); |
| 92 |
add_action( 'propertyhive_process_viewing_meta', 'PH_Meta_Box_Viewing_Property::save', 25, 2 ); |
| 93 |
|
| 94 |
// Save Offer Meta Boxes |
| 95 |
add_action( 'propertyhive_process_offer_meta', 'PH_Meta_Box_Offer_Details::save', 10, 2 ); |
| 96 |
add_action( 'propertyhive_process_offer_meta', 'PH_Meta_Box_Offer_Applicant::save', 15, 2 ); |
| 97 |
add_action( 'propertyhive_process_offer_meta', 'PH_Meta_Box_Offer_Applicant_Solicitor::save', 20, 2 ); |
| 98 |
add_action( 'propertyhive_process_offer_meta', 'PH_Meta_Box_Offer_Property::save', 25, 2 ); |
| 99 |
add_action( 'propertyhive_process_offer_meta', 'PH_Meta_Box_Offer_Property_Owner_Solicitor::save', 30, 2 ); |
| 100 |
|
| 101 |
// Save Sale Meta Boxes |
| 102 |
add_action( 'propertyhive_process_sale_meta', 'PH_Meta_Box_Sale_Details::save', 10, 2 ); |
| 103 |
add_action( 'propertyhive_process_sale_meta', 'PH_Meta_Box_Sale_Applicant_Solicitor::save', 15, 2 ); |
| 104 |
add_action( 'propertyhive_process_sale_meta', 'PH_Meta_Box_Sale_Property_Owner_Solicitor::save', 20, 2 ); |
| 105 |
|
| 106 |
// Save Tenancy Meta Boxes |
| 107 |
add_action( 'propertyhive_process_tenancy_meta', 'PH_Meta_Box_Tenancy_Details::save', 10, 2 ); |
| 108 |
add_action( 'propertyhive_process_tenancy_meta', 'PH_Meta_Box_Tenancy_Applicant::save', 15, 2 ); |
| 109 |
add_action( 'propertyhive_process_tenancy_meta', 'PH_Meta_Box_Tenancy_Property::save', 20, 2 ); |
| 110 |
add_action( 'propertyhive_process_tenancy_meta', 'PH_Meta_Box_Tenancy_Deposit_Scheme::save', 25, 2 ); |
| 111 |
add_action( 'propertyhive_process_tenancy_meta', 'PH_Meta_Box_Tenancy_Meter_Readings::save', 25, 2 ); |
| 112 |
add_action( 'propertyhive_process_tenancy_meta', 'PH_Meta_Box_Tenancy_Management::save', 30, 2 ); |
| 113 |
|
| 114 |
// Error handling (for showing errors from meta boxes on next page load) |
| 115 |
add_action( 'admin_notices', array( $this, 'output_errors' ) ); |
| 116 |
add_action( 'shutdown', array( $this, 'save_errors' ) ); |
| 117 |
|
| 118 |
add_filter( 'redirect_post_location', array( $this, 'redirect_to_tab' ), 10, 2 ); |
| 119 |
|
| 120 |
$this->check_contact_create_relationship(); |
| 121 |
$this->check_contact_delete_relationship(); |
| 122 |
$this->check_remove_solicitor(); |
| 123 |
$this->check_create_offer(); |
| 124 |
$this->check_create_sale(); |
| 125 |
$this->check_create_tenancy(); |
| 126 |
} |
| 127 |
|
| 128 |
function add_archive_link_to_post_submitbox() |
| 129 |
{ |
| 130 |
global $post, $current_screen; |
| 131 |
|
| 132 |
if ( isset($current_screen) && $current_screen->base === 'post' && $current_screen->action === 'add' ) |
| 133 |
return; |
| 134 |
|
| 135 |
// Check if the post status is not 'archive' |
| 136 |
$post_types = array('property', 'contact', 'appraisal', 'viewing', 'offer', 'sale', 'tenancy', 'key_date'); |
| 137 |
$post_types = apply_filters( 'propertyhive_post_types_with_archive', $post_types ); |
| 138 |
|
| 139 |
if ( in_array($post->post_type, $post_types) ) |
| 140 |
{ |
| 141 |
if ( $post->post_status != 'archive' ) |
| 142 |
{ |
| 143 |
echo '<div id="archive-action" style="float:left; line-height:2.30769231">'; |
| 144 |
$archive_url = wp_nonce_url(admin_url('post.php?post=' . $post->ID . '&action=archive_single'), 'archive-post_' . $post->ID); |
| 145 |
echo '<a href="' . esc_url($archive_url) . '" id="archive-post" class="submitdelete deletion">' . esc_html( __('Archive', 'propertyhive') ) . '</a> | '; |
| 146 |
echo '</div>'; |
| 147 |
} |
| 148 |
else |
| 149 |
{ |
| 150 |
// This is an archived post |
| 151 |
echo '<div id="archive-action" style="float:left; line-height:2.30769231">'; |
| 152 |
$archive_url = wp_nonce_url(admin_url('post.php?post=' . $post->ID . '&action=unarchive_single'), 'unarchive-post_' . $post->ID); |
| 153 |
echo '<a href="' . esc_url($archive_url) . '" id="unarchive-post" class="submitdelete deletion">' . esc_html( __('Unarchive', 'propertyhive') ) . '</a> | '; |
| 154 |
echo '</div>'; |
| 155 |
} |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 159 |
public function redirect_to_tab( $url, $post_id ) |
| 160 |
{ |
| 161 |
if ( isset($_POST['propertyhive_selected_metabox_tab']) ) |
| 162 |
{ |
| 163 |
$url .= '#' . $_POST['propertyhive_selected_metabox_tab']; |
| 164 |
} |
| 165 |
|
| 166 |
return $url; |
| 167 |
} |
| 168 |
|
| 169 |
public function check_contact_create_relationship() |
| 170 |
{ |
| 171 |
if ( isset($_GET['add_applicant_relationship']) && wp_verify_nonce($_GET['add_applicant_relationship'], '1') && isset($_GET['post']) ) |
| 172 |
{ |
| 173 |
// Need to add blank applicant |
| 174 |
if ( get_post_type((int)$_GET['post']) != 'contact' ) |
| 175 |
return; |
| 176 |
|
| 177 |
$num_applicant_profiles = get_post_meta( (int)$_GET['post'], '_applicant_profiles', TRUE ); |
| 178 |
if ( $num_applicant_profiles == '' ) |
| 179 |
{ |
| 180 |
$num_applicant_profiles = 0; |
| 181 |
} |
| 182 |
|
| 183 |
update_post_meta( (int)$_GET['post'], '_applicant_profile_' . $num_applicant_profiles, '' ); |
| 184 |
update_post_meta( (int)$_GET['post'], '_applicant_profiles', $num_applicant_profiles + 1 ); |
| 185 |
|
| 186 |
$existing_contact_types = get_post_meta( (int)$_GET['post'], '_contact_types', TRUE ); |
| 187 |
if ( $existing_contact_types == '' || !is_array($existing_contact_types) ) |
| 188 |
{ |
| 189 |
$existing_contact_types = array(); |
| 190 |
} |
| 191 |
if ( !in_array( 'applicant', $existing_contact_types ) ) |
| 192 |
{ |
| 193 |
$existing_contact_types[] = 'applicant'; |
| 194 |
update_post_meta( (int)$_GET['post'], '_contact_types', $existing_contact_types ); |
| 195 |
} |
| 196 |
|
| 197 |
// Do redirect |
| 198 |
wp_redirect( admin_url( 'post.php?post=' . (int)$_GET['post'] . '&action=edit#propertyhive-contact-relationships' ) ); |
| 199 |
exit(); |
| 200 |
} |
| 201 |
|
| 202 |
if ( isset($_GET['add_third_party_relationship']) && wp_verify_nonce($_GET['add_third_party_relationship'], '1') && isset($_GET['post']) ) |
| 203 |
{ |
| 204 |
// Need to add blank third party relationship |
| 205 |
if ( get_post_type((int)$_GET['post']) != 'contact' ) |
| 206 |
return; |
| 207 |
|
| 208 |
$existing_third_party_categories = get_post_meta( (int)$_GET['post'], '_third_party_categories', TRUE ); |
| 209 |
if ( !is_array($existing_third_party_categories) ) |
| 210 |
{ |
| 211 |
$existing_third_party_categories = array(); |
| 212 |
} |
| 213 |
$existing_third_party_categories[] = 0; |
| 214 |
update_post_meta( $_GET['post'], '_third_party_categories', $existing_third_party_categories ); |
| 215 |
|
| 216 |
$existing_contact_types = get_post_meta( (int)$_GET['post'], '_contact_types', TRUE ); |
| 217 |
if ( $existing_contact_types == '' || !is_array($existing_contact_types) ) |
| 218 |
{ |
| 219 |
$existing_contact_types = array(); |
| 220 |
} |
| 221 |
if ( !in_array( 'thirdparty', $existing_contact_types ) ) |
| 222 |
{ |
| 223 |
$existing_contact_types[] = 'thirdparty'; |
| 224 |
update_post_meta( (int)$_GET['post'], '_contact_types', $existing_contact_types ); |
| 225 |
} |
| 226 |
} |
| 227 |
} |
| 228 |
|
| 229 |
public function check_contact_delete_relationship() |
| 230 |
{ |
| 231 |
if ( isset($_GET['delete_applicant_relationship']) && isset($_GET['post']) ) |
| 232 |
{ |
| 233 |
// Need to add blank applicant |
| 234 |
if ( get_post_type((int)$_GET['post']) != 'contact' ) |
| 235 |
return; |
| 236 |
|
| 237 |
$num_applicant_profiles = get_post_meta( (int)$_GET['post'], '_applicant_profiles', TRUE ); |
| 238 |
if ( $num_applicant_profiles == '' ) |
| 239 |
{ |
| 240 |
$num_applicant_profiles = 0; |
| 241 |
} |
| 242 |
|
| 243 |
for ( $i = 0; $i < $num_applicant_profiles; ++$i ) |
| 244 |
{ |
| 245 |
if ( wp_verify_nonce($_GET['delete_applicant_relationship'], $i) ) |
| 246 |
{ |
| 247 |
$deleting_applicant_profile = $i; |
| 248 |
|
| 249 |
// We're deleting this one |
| 250 |
delete_post_meta( (int)$_GET['post'], '_applicant_profile_' . $i ); |
| 251 |
|
| 252 |
// Now need to rename any that are higher than $deleting_applicant_profile |
| 253 |
for ( $j = 0; $j < $num_applicant_profiles; ++$j ) |
| 254 |
{ |
| 255 |
if ( $j > $deleting_applicant_profile ) |
| 256 |
{ |
| 257 |
$this_applicant_profile = get_post_meta( (int)$_GET['post'], '_applicant_profile_' . $j, true ); |
| 258 |
update_post_meta( (int)$_GET['post'], '_applicant_profile_' . ($j - 1), $this_applicant_profile ); |
| 259 |
delete_post_meta( (int)$_GET['post'], '_applicant_profile_' . $j ); |
| 260 |
} |
| 261 |
} |
| 262 |
|
| 263 |
// remove from _contact_types if no more profiles left |
| 264 |
if ( $num_applicant_profiles == 1 ) |
| 265 |
{ |
| 266 |
$existing_contact_types = get_post_meta( (int)$_GET['post'], '_contact_types', TRUE ); |
| 267 |
if ( $existing_contact_types == '' || !is_array($existing_contact_types) ) |
| 268 |
{ |
| 269 |
$existing_contact_types = array(); |
| 270 |
} |
| 271 |
if( ( $key = array_search('applicant', $existing_contact_types) ) !== false ) |
| 272 |
{ |
| 273 |
unset($existing_contact_types[$key]); |
| 274 |
} |
| 275 |
update_post_meta( (int)$_GET['post'], '_contact_types', $existing_contact_types ); |
| 276 |
} |
| 277 |
|
| 278 |
update_post_meta( (int)$_GET['post'], '_applicant_profiles', $num_applicant_profiles - 1 ); |
| 279 |
|
| 280 |
// update applicant departments |
| 281 |
$hot_applicant = ''; |
| 282 |
$applicant_departments = array(); |
| 283 |
|
| 284 |
$num_applicant_profiles = get_post_meta( (int)$_GET['post'], '_applicant_profiles', TRUE ); |
| 285 |
if ( $num_applicant_profiles == '' ) |
| 286 |
{ |
| 287 |
$num_applicant_profiles = 0; |
| 288 |
} |
| 289 |
|
| 290 |
for ( $j = 0; $j < $num_applicant_profiles; ++$j ) |
| 291 |
{ |
| 292 |
$applicant_profile = get_post_meta( (int)$_GET['post'], '_applicant_profile_' . $j, true ); |
| 293 |
|
| 294 |
if ( isset($applicant_profile['department']) && !empty($applicant_profile['department']) ) |
| 295 |
{ |
| 296 |
$applicant_departments[] = $applicant_profile['department']; |
| 297 |
} |
| 298 |
|
| 299 |
if ( isset($applicant_profile['grading']) && ph_clean($applicant_profile['grading']) == 'yes' ) |
| 300 |
{ |
| 301 |
$hot_applicant = 'yes'; |
| 302 |
} |
| 303 |
} |
| 304 |
|
| 305 |
update_post_meta( (int)$_GET['post'], '_hot_applicant', $hot_applicant ); |
| 306 |
|
| 307 |
if ( !empty($applicant_departments) ) |
| 308 |
{ |
| 309 |
$applicant_departments = array_filter($applicant_departments); |
| 310 |
$applicant_departments = array_unique($applicant_departments); |
| 311 |
} |
| 312 |
update_post_meta( (int)$_GET['post'], '_applicant_departments', $applicant_departments ); |
| 313 |
|
| 314 |
// Do redirect |
| 315 |
wp_redirect( admin_url( 'post.php?post=' . (int)$_GET['post'] . '&action=edit#propertyhive-contact-relationships' ) ); |
| 316 |
exit(); |
| 317 |
} |
| 318 |
} |
| 319 |
} |
| 320 |
} |
| 321 |
|
| 322 |
public function check_remove_solicitor() |
| 323 |
{ |
| 324 |
if ( isset($_GET['remove_contact_solicitor']) && isset($_GET['post']) ) |
| 325 |
{ |
| 326 |
if ( get_post_type((int)$_GET['post']) != 'contact' ) |
| 327 |
return; |
| 328 |
|
| 329 |
update_post_meta( (int)$_GET['post'], '_contact_solicitor_contact_id', '' ); |
| 330 |
} |
| 331 |
|
| 332 |
if ( isset($_GET['remove_property_owner_solicitor']) && isset($_GET['post']) ) |
| 333 |
{ |
| 334 |
if ( get_post_type((int)$_GET['post']) != 'offer' && get_post_type((int)$_GET['post']) != 'sale' ) |
| 335 |
return; |
| 336 |
|
| 337 |
update_post_meta( (int)$_GET['post'], '_property_owner_solicitor_contact_id', '' ); |
| 338 |
} |
| 339 |
|
| 340 |
if ( isset($_GET['remove_applicant_solicitor']) && isset($_GET['post']) ) |
| 341 |
{ |
| 342 |
if ( get_post_type((int)$_GET['post']) != 'offer' && get_post_type((int)$_GET['post']) != 'sale' ) |
| 343 |
return; |
| 344 |
|
| 345 |
update_post_meta( (int)$_GET['post'], '_applicant_solicitor_contact_id', '' ); |
| 346 |
} |
| 347 |
} |
| 348 |
|
| 349 |
public function check_create_offer() |
| 350 |
{ |
| 351 |
if ( isset($_GET['create_offer']) && isset($_GET['post']) ) |
| 352 |
{ |
| 353 |
if ( get_post_type((int)$_GET['post']) != 'viewing') |
| 354 |
return; |
| 355 |
|
| 356 |
$viewing = new PH_Viewing((int)$_GET['post']); |
| 357 |
|
| 358 |
$viewing_applicant_ids = $viewing->get_applicant_ids(); |
| 359 |
|
| 360 |
$offer_post = array( |
| 361 |
'post_title' => '', |
| 362 |
'post_content' => '', |
| 363 |
'post_type' => 'offer', |
| 364 |
'post_status' => 'publish', |
| 365 |
'comment_status' => 'closed', |
| 366 |
'ping_status' => 'closed', |
| 367 |
); |
| 368 |
|
| 369 |
// Insert the post into the database |
| 370 |
$offer_post_id = wp_insert_post( $offer_post ); |
| 371 |
|
| 372 |
add_post_meta( $offer_post_id, '_status', 'pending' ); |
| 373 |
add_post_meta( $offer_post_id, '_amount', '' ); |
| 374 |
|
| 375 |
$applicant_solicitor_contact_id = ''; |
| 376 |
foreach( $viewing_applicant_ids as $viewing_applicant_id ) |
| 377 |
{ |
| 378 |
add_post_meta( $offer_post_id, '_applicant_contact_id', $viewing_applicant_id ); |
| 379 |
|
| 380 |
// If any applicant has a solicitor assigned, select them as the offer applicant solicitor |
| 381 |
if ( empty($applicant_solicitor_contact_id) ) |
| 382 |
{ |
| 383 |
if ( !empty( get_post_meta( $viewing_applicant_id, '_contact_solicitor_contact_id', TRUE ) ) ) |
| 384 |
{ |
| 385 |
$applicant_solicitor_contact_id = get_post_meta( $viewing_applicant_id, '_contact_solicitor_contact_id', TRUE ); |
| 386 |
} |
| 387 |
} |
| 388 |
} |
| 389 |
|
| 390 |
add_post_meta( $offer_post_id, '_applicant_solicitor_contact_id', $applicant_solicitor_contact_id ); |
| 391 |
add_post_meta( $offer_post_id, '_property_id', $viewing->property_id ); |
| 392 |
|
| 393 |
// If any owner has a solicitor assigned, select them as the offer owner solicitor |
| 394 |
$property_owner_solicitor_contact_id = ''; |
| 395 |
|
| 396 |
$owner_contact_ids = get_post_meta($viewing->property_id, '_owner_contact_id', TRUE); |
| 397 |
if ( !empty( $owner_contact_ids ) ) |
| 398 |
{ |
| 399 |
if ( !is_array($owner_contact_ids) ) |
| 400 |
{ |
| 401 |
$owner_contact_ids = array($owner_contact_ids); |
| 402 |
} |
| 403 |
|
| 404 |
foreach( $owner_contact_ids as $owner_contact_id ) |
| 405 |
{ |
| 406 |
if ( empty($property_owner_solicitor_contact_id) ) |
| 407 |
{ |
| 408 |
if ( !empty( get_post_meta( $owner_contact_id, '_contact_solicitor_contact_id', TRUE ) ) ) |
| 409 |
{ |
| 410 |
$property_owner_solicitor_contact_id = get_post_meta( $owner_contact_id, '_contact_solicitor_contact_id', TRUE ); |
| 411 |
} |
| 412 |
} |
| 413 |
} |
| 414 |
} |
| 415 |
add_post_meta( $offer_post_id, '_property_owner_solicitor_contact_id', $property_owner_solicitor_contact_id ); |
| 416 |
|
| 417 |
add_post_meta( $offer_post_id, '_offer_date_time', date("Y-m-d H:i:s") ); |
| 418 |
|
| 419 |
update_post_meta( (int)$_GET['post'], '_offer_id', $offer_post_id ); |
| 420 |
update_post_meta( (int)$_GET['post'], '_status', 'offer_made' ); |
| 421 |
|
| 422 |
$current_user = wp_get_current_user(); |
| 423 |
|
| 424 |
// Add note/comment to viewing |
| 425 |
$comment = array( |
| 426 |
'note_type' => 'action', |
| 427 |
'action' => 'viewing_offer_made', |
| 428 |
); |
| 429 |
|
| 430 |
$data = array( |
| 431 |
'comment_post_ID' => (int)$_GET['post'], |
| 432 |
'comment_author' => $current_user->display_name, |
| 433 |
'comment_author_email' => 'propertyhive@noreply.com', |
| 434 |
'comment_author_url' => '', |
| 435 |
'comment_date' => date("Y-m-d H:i:s"), |
| 436 |
'comment_content' => serialize($comment), |
| 437 |
'comment_approved' => 1, |
| 438 |
'comment_type' => 'propertyhive_note', |
| 439 |
); |
| 440 |
$comment_id = wp_insert_comment( $data ); |
| 441 |
|
| 442 |
// Do redirect |
| 443 |
wp_redirect( admin_url( 'post.php?post=' . $offer_post_id . '&action=edit' ) ); |
| 444 |
exit(); |
| 445 |
} |
| 446 |
|
| 447 |
} |
| 448 |
|
| 449 |
public function check_create_sale() |
| 450 |
{ |
| 451 |
if ( isset($_GET['create_sale']) && isset($_GET['post']) ) |
| 452 |
{ |
| 453 |
if ( get_post_type((int)$_GET['post']) != 'offer') |
| 454 |
return; |
| 455 |
|
| 456 |
$offer = new PH_Offer((int)$_GET['post']); |
| 457 |
|
| 458 |
$offer_applicant_ids = $offer->get_applicant_ids(); |
| 459 |
|
| 460 |
$sale_post = array( |
| 461 |
'post_title' => '', |
| 462 |
'post_content' => '', |
| 463 |
'post_type' => 'sale', |
| 464 |
'post_status' => 'publish', |
| 465 |
'comment_status' => 'closed', |
| 466 |
'ping_status' => 'closed', |
| 467 |
); |
| 468 |
|
| 469 |
// Insert the post into the database |
| 470 |
$sale_post_id = wp_insert_post( $sale_post ); |
| 471 |
|
| 472 |
add_post_meta( $sale_post_id, '_status', 'current' ); |
| 473 |
add_post_meta( $sale_post_id, '_amount', $offer->amount ); |
| 474 |
|
| 475 |
foreach( $offer_applicant_ids as $offer_applicant_id ) |
| 476 |
{ |
| 477 |
add_post_meta( $sale_post_id, '_applicant_contact_id', $offer_applicant_id ); |
| 478 |
} |
| 479 |
|
| 480 |
add_post_meta( $sale_post_id, '_applicant_solicitor_contact_id', $offer->applicant_solicitor_contact_id ); |
| 481 |
add_post_meta( $sale_post_id, '_property_id', $offer->property_id ); |
| 482 |
add_post_meta( $sale_post_id, '_property_owner_solicitor_contact_id', $offer->property_owner_solicitor_contact_id ); |
| 483 |
add_post_meta( $sale_post_id, '_sale_date_time', date("Y-m-d H:i:s") ); |
| 484 |
|
| 485 |
update_post_meta( (int)$_GET['post'], '_sale_id', $sale_post_id ); |
| 486 |
|
| 487 |
$current_user = wp_get_current_user(); |
| 488 |
|
| 489 |
// Add note/comment to offer |
| 490 |
$comment = array( |
| 491 |
'note_type' => 'action', |
| 492 |
'action' => 'offer_sale_created', |
| 493 |
); |
| 494 |
|
| 495 |
$data = array( |
| 496 |
'comment_post_ID' => (int)$_GET['post'], |
| 497 |
'comment_author' => $current_user->display_name, |
| 498 |
'comment_author_email' => 'propertyhive@noreply.com', |
| 499 |
'comment_author_url' => '', |
| 500 |
'comment_date' => date("Y-m-d H:i:s"), |
| 501 |
'comment_content' => serialize($comment), |
| 502 |
'comment_approved' => 1, |
| 503 |
'comment_type' => 'propertyhive_note', |
| 504 |
); |
| 505 |
$comment_id = wp_insert_comment( $data ); |
| 506 |
|
| 507 |
// Do redirect |
| 508 |
wp_redirect( admin_url( 'post.php?post=' . $sale_post_id . '&action=edit' ) ); |
| 509 |
exit(); |
| 510 |
} |
| 511 |
|
| 512 |
} |
| 513 |
|
| 514 |
public function check_create_tenancy() { |
| 515 |
if ( isset( $_GET['create_tenancy'] ) && isset( $_GET['post'] ) ) { |
| 516 |
if ( get_post_type( (int) $_GET['post'] ) != 'viewing' ) { |
| 517 |
return; |
| 518 |
} |
| 519 |
|
| 520 |
$viewing = new PH_Viewing( (int) $_GET['post'] ); |
| 521 |
|
| 522 |
$viewing_applicant_ids = $viewing->get_applicant_ids(); |
| 523 |
|
| 524 |
$tenancy_post = array( |
| 525 |
'post_title' => '', |
| 526 |
'post_content' => '', |
| 527 |
'post_type' => 'tenancy', |
| 528 |
'post_status' => 'publish', |
| 529 |
'comment_status' => 'closed', |
| 530 |
'ping_status' => 'closed', |
| 531 |
); |
| 532 |
|
| 533 |
// Insert the post into the database |
| 534 |
$tenancy_post_id = wp_insert_post( $tenancy_post ); |
| 535 |
|
| 536 |
$property_id = $viewing->property_id; |
| 537 |
|
| 538 |
foreach( $viewing_applicant_ids as $viewing_applicant_id ) |
| 539 |
{ |
| 540 |
add_post_meta( $tenancy_post_id, '_applicant_contact_id', $viewing_applicant_id ); |
| 541 |
} |
| 542 |
|
| 543 |
add_post_meta( $tenancy_post_id, '_property_id', $viewing->property_id ); |
| 544 |
|
| 545 |
add_post_meta( $tenancy_post_id, '_rent', get_post_meta( $property_id, '_rent', true ) ); |
| 546 |
add_post_meta( $tenancy_post_id, '_rent_frequency', get_post_meta( $property_id, '_rent_frequency', true ) ); |
| 547 |
add_post_meta( $tenancy_post_id, '_price_actual', get_post_meta( $property_id, '_price_actual', true ) ); |
| 548 |
add_post_meta( $tenancy_post_id, '_currency', get_post_meta( $property_id, '_currency', true ) ); |
| 549 |
|
| 550 |
add_post_meta( $tenancy_post_id, '_deposit', get_post_meta( $property_id, '_deposit', true ) ); |
| 551 |
|
| 552 |
update_post_meta( (int) $_GET['post'], '_tenancy_id', $tenancy_post_id ); |
| 553 |
update_post_meta( (int) $_GET['post'], '_status', 'offer_made' ); |
| 554 |
|
| 555 |
$current_user = wp_get_current_user(); |
| 556 |
|
| 557 |
// Add note/comment to viewing |
| 558 |
$comment = array( |
| 559 |
'note_type' => 'action', |
| 560 |
'action' => 'viewing_offer_made', |
| 561 |
); |
| 562 |
|
| 563 |
$data = array( |
| 564 |
'comment_post_ID' => (int) $_GET['post'], |
| 565 |
'comment_author' => $current_user->display_name, |
| 566 |
'comment_author_email' => 'propertyhive@noreply.com', |
| 567 |
'comment_author_url' => '', |
| 568 |
'comment_date' => date( "Y-m-d H:i:s" ), |
| 569 |
'comment_content' => serialize( $comment ), |
| 570 |
'comment_approved' => 1, |
| 571 |
'comment_type' => 'propertyhive_note', |
| 572 |
); |
| 573 |
$comment_id = wp_insert_comment( $data ); |
| 574 |
|
| 575 |
// Do redirect |
| 576 |
wp_redirect( admin_url( 'post.php?post=' . $tenancy_post_id . '&action=edit' ) ); |
| 577 |
exit(); |
| 578 |
} |
| 579 |
|
| 580 |
} |
| 581 |
|
| 582 |
/** |
| 583 |
* Add an error message |
| 584 |
* @param string $text |
| 585 |
*/ |
| 586 |
public static function add_error( $text ) { |
| 587 |
self::$meta_box_errors[] = $text; |
| 588 |
} |
| 589 |
|
| 590 |
/** |
| 591 |
* Save errors to an option |
| 592 |
*/ |
| 593 |
public function save_errors() { |
| 594 |
update_option( 'propertyhivemeta_box_errors', self::$meta_box_errors ); |
| 595 |
} |
| 596 |
|
| 597 |
/** |
| 598 |
* Show any stored error messages. |
| 599 |
*/ |
| 600 |
public function output_errors() { |
| 601 |
|
| 602 |
$errors = @unserialize( get_option( 'propertyhive_meta_box_errors' ), ['allowed_classes' => false] ); |
| 603 |
|
| 604 |
if ( $errors !== false && !empty( $errors ) ) { |
| 605 |
|
| 606 |
echo '<div id="propertyhive_errors" class="error fade">'; |
| 607 |
foreach ( $errors as $error ) { |
| 608 |
echo '<p>' . esc_html( $error ) . '</p>'; |
| 609 |
} |
| 610 |
echo '</div>'; |
| 611 |
|
| 612 |
// Clear |
| 613 |
delete_option( 'propertyhive_meta_box_errors' ); |
| 614 |
} |
| 615 |
} |
| 616 |
|
| 617 |
/** |
| 618 |
* Add PH Meta boxes |
| 619 |
*/ |
| 620 |
public function add_meta_boxes() { |
| 621 |
|
| 622 |
global $tabs, $post, $pagenow; |
| 623 |
|
| 624 |
// PROPERTY |
| 625 |
if (!isset($tabs)) $tabs = array(); |
| 626 |
|
| 627 |
/* PROPERTY SUMMARY META BOXES */ |
| 628 |
$meta_boxes = array(); |
| 629 |
|
| 630 |
$pinned_notes_args = array(); |
| 631 |
$pinned_notes = array(); |
| 632 |
if ( $pagenow != 'post-new.php' && isset($post->post_type) && in_array( |
| 633 |
$post->post_type, |
| 634 |
apply_filters( 'propertyhive_post_types_with_tabs', array('property', 'contact', 'enquiry', 'appraisal', 'viewing', 'offer', 'sale', 'tenancy') ) |
| 635 |
) ) |
| 636 |
{ |
| 637 |
$pinned_notes_args = array( |
| 638 |
'post_id' => (int)$post->ID, |
| 639 |
'type' => 'propertyhive_note', |
| 640 |
'fields' => 'ids', |
| 641 |
'search' => '"pinned";s:1:"1"', |
| 642 |
'meta_query' => array( |
| 643 |
array( |
| 644 |
'key' => 'related_to', |
| 645 |
'value' => '"' . (int)$post->ID . '"', |
| 646 |
'compare' => 'LIKE', |
| 647 |
), |
| 648 |
) |
| 649 |
); |
| 650 |
|
| 651 |
$pinned_notes = get_comments( $pinned_notes_args ); |
| 652 |
} |
| 653 |
|
| 654 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'property' ) |
| 655 |
{ |
| 656 |
if ( !empty($pinned_notes) ) |
| 657 |
{ |
| 658 |
$meta_boxes[1] = array( |
| 659 |
'id' => 'propertyhive-property-pinned-notes', |
| 660 |
'title' => __( 'Pinned Notes', 'propertyhive' ), |
| 661 |
'callback' => 'PH_Meta_Box_Property_Pinned_Notes::output', |
| 662 |
'screen' => 'property', |
| 663 |
'context' => 'normal', |
| 664 |
'priority' => 'high', |
| 665 |
); |
| 666 |
} |
| 667 |
} |
| 668 |
$meta_boxes[5] = array( |
| 669 |
'id' => 'propertyhive-property-address', |
| 670 |
'title' => __( 'Property Address', 'propertyhive' ), |
| 671 |
'callback' => 'PH_Meta_Box_Property_Address::output', |
| 672 |
'screen' => 'property', |
| 673 |
'context' => 'normal', |
| 674 |
'priority' => 'high' |
| 675 |
); |
| 676 |
if ( get_option('propertyhive_module_disabled_contacts', '') != 'yes' ) |
| 677 |
{ |
| 678 |
$meta_boxes[10] = array( |
| 679 |
'id' => 'propertyhive-property-owner', |
| 680 |
'title' => __( 'Property Owner / Landlord', 'propertyhive' ), |
| 681 |
'callback' => 'PH_Meta_Box_Property_Owner::output', |
| 682 |
'screen' => 'property', |
| 683 |
'context' => 'normal', |
| 684 |
'priority' => 'high' |
| 685 |
); |
| 686 |
} |
| 687 |
$meta_boxes[15] = array( |
| 688 |
'id' => 'propertyhive-property-record-details', |
| 689 |
'title' => __( 'Record Details', 'propertyhive' ), |
| 690 |
'callback' => 'PH_Meta_Box_Property_Record_Details::output', |
| 691 |
'screen' => 'property', |
| 692 |
'context' => 'normal', |
| 693 |
'priority' => 'high' |
| 694 |
); |
| 695 |
$meta_boxes[20] = array( |
| 696 |
'id' => 'propertyhive-property-coordinates', |
| 697 |
'title' => __( 'Property Location', 'propertyhive' ), |
| 698 |
'callback' => 'PH_Meta_Box_Property_Coordinates::output', |
| 699 |
'screen' => 'property', |
| 700 |
'context' => 'normal', |
| 701 |
'priority' => 'high' |
| 702 |
); |
| 703 |
|
| 704 |
$meta_boxes = apply_filters( 'propertyhive_property_summary_meta_boxes', $meta_boxes ); |
| 705 |
ksort($meta_boxes); |
| 706 |
|
| 707 |
$ids = array(); |
| 708 |
foreach ($meta_boxes as $meta_box) |
| 709 |
{ |
| 710 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 711 |
$ids[] = $meta_box['id']; |
| 712 |
} |
| 713 |
|
| 714 |
$tabs['tab_summary'] = array( |
| 715 |
'name' => __( 'Summary', 'propertyhive' ), |
| 716 |
'metabox_ids' => $ids, |
| 717 |
'post_type' => 'property' |
| 718 |
); |
| 719 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'property' ) |
| 720 |
{ |
| 721 |
$tabs['tab_summary']['ajax_actions'] = array( '^^ph_redraw_pinned_notes_grid(\'property\')' ); |
| 722 |
} |
| 723 |
|
| 724 |
/* PROPERTY DETAILS META BOXES */ |
| 725 |
$meta_boxes = array(); |
| 726 |
$meta_boxes[5] = array( |
| 727 |
'id' => 'propertyhive-property-department', |
| 728 |
'title' => __( 'Property Department', 'propertyhive' ), |
| 729 |
'callback' => 'PH_Meta_Box_Property_Department::output', |
| 730 |
'screen' => 'property', |
| 731 |
'context' => 'normal', |
| 732 |
'priority' => 'high' |
| 733 |
); |
| 734 |
$meta_boxes[10] = array( |
| 735 |
'id' => 'propertyhive-property-residential-sales-details', |
| 736 |
'title' => __( 'Residential Sales Details', 'propertyhive' ), |
| 737 |
'callback' => 'PH_Meta_Box_Property_Residential_Sales_Details::output', |
| 738 |
'screen' => 'property', |
| 739 |
'context' => 'normal', |
| 740 |
'priority' => 'high' |
| 741 |
); |
| 742 |
$meta_boxes[15] = array( |
| 743 |
'id' => 'propertyhive-property-residential-lettings-details', |
| 744 |
'title' => __( 'Residential Lettings Details', 'propertyhive' ), |
| 745 |
'callback' => 'PH_Meta_Box_Property_Residential_Lettings_Details::output', |
| 746 |
'screen' => 'property', |
| 747 |
'context' => 'normal', |
| 748 |
'priority' => 'high' |
| 749 |
); |
| 750 |
$meta_boxes[20] = array( |
| 751 |
'id' => 'propertyhive-property-residential-details', |
| 752 |
'title' => __( 'Residential Details', 'propertyhive' ), |
| 753 |
'callback' => 'PH_Meta_Box_Property_Residential_Details::output', |
| 754 |
'screen' => 'property', |
| 755 |
'context' => 'normal', |
| 756 |
'priority' => 'high' |
| 757 |
); |
| 758 |
$meta_boxes[25] = array( |
| 759 |
'id' => 'propertyhive-property-commercial-details', |
| 760 |
'title' => __( 'Commercial Details', 'propertyhive' ), |
| 761 |
'callback' => 'PH_Meta_Box_Property_Commercial_Details::output', |
| 762 |
'screen' => 'property', |
| 763 |
'context' => 'normal', |
| 764 |
'priority' => 'high' |
| 765 |
); |
| 766 |
$meta_boxes[30] = array( |
| 767 |
'id' => 'propertyhive-property-material-information', |
| 768 |
'title' => __( 'Utilities & Additional Information', 'propertyhive' ), |
| 769 |
'callback' => 'PH_Meta_Box_Property_Material_Information::output', |
| 770 |
'screen' => 'property', |
| 771 |
'context' => 'normal', |
| 772 |
'priority' => 'high' |
| 773 |
); |
| 774 |
|
| 775 |
$meta_boxes = apply_filters( 'propertyhive_property_details_meta_boxes', $meta_boxes ); |
| 776 |
ksort($meta_boxes); |
| 777 |
|
| 778 |
$ids = array(); |
| 779 |
foreach ($meta_boxes as $meta_box) |
| 780 |
{ |
| 781 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 782 |
$ids[] = $meta_box['id']; |
| 783 |
} |
| 784 |
|
| 785 |
$tabs['tab_details'] = array( |
| 786 |
'name' => __( 'Details', 'propertyhive' ), |
| 787 |
'metabox_ids' => $ids, |
| 788 |
'post_type' => 'property' |
| 789 |
); |
| 790 |
|
| 791 |
if ( |
| 792 |
( |
| 793 |
get_post_meta( $post->ID, '_department', TRUE ) == 'commercial' || |
| 794 |
ph_get_custom_department_based_on(get_post_meta( $post->ID, '_department', TRUE )) == 'commercial' |
| 795 |
) && |
| 796 |
isset($post->post_parent) && |
| 797 |
$post->post_parent == 0 |
| 798 |
) |
| 799 |
{ |
| 800 |
$meta_boxes = array(); |
| 801 |
$meta_boxes[5] = array( |
| 802 |
'id' => 'propertyhive-property-commercial-units', |
| 803 |
'title' => __( 'Commercial Units', 'propertyhive' ), |
| 804 |
'callback' => 'PH_Meta_Box_Property_Commercial_Units::output', |
| 805 |
'screen' => 'property', |
| 806 |
'context' => 'normal', |
| 807 |
'priority' => 'high' |
| 808 |
); |
| 809 |
|
| 810 |
$meta_boxes = apply_filters( 'propertyhive_property_commercial_units_meta_boxes', $meta_boxes ); |
| 811 |
ksort($meta_boxes); |
| 812 |
|
| 813 |
$ids = array(); |
| 814 |
foreach ($meta_boxes as $meta_box) |
| 815 |
{ |
| 816 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 817 |
$ids[] = $meta_box['id']; |
| 818 |
} |
| 819 |
|
| 820 |
$tabs['tab_units'] = array( |
| 821 |
'name' => __( 'Units', 'propertyhive' ), |
| 822 |
'metabox_ids' => $ids, |
| 823 |
'post_type' => 'property' |
| 824 |
); |
| 825 |
} |
| 826 |
|
| 827 |
/* PROPERTY MARKETING META BOXES */ |
| 828 |
$meta_boxes = array(); |
| 829 |
$meta_boxes[5] = array( |
| 830 |
'id' => 'propertyhive-property-marketing', |
| 831 |
'title' => __( 'Property Marketing', 'propertyhive' ), |
| 832 |
'callback' => 'PH_Meta_Box_Property_Marketing::output', |
| 833 |
'screen' => 'property', |
| 834 |
'context' => 'normal', |
| 835 |
'priority' => 'high' |
| 836 |
); |
| 837 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'property' ) |
| 838 |
{ |
| 839 |
$meta_boxes[10] = array( |
| 840 |
'id' => 'propertyhive-property-marketing-statistics', |
| 841 |
'title' => __( 'Property Marketing Statistics', 'propertyhive' ), |
| 842 |
'callback' => 'PH_Meta_Box_Property_Marketing_Statistics::output', |
| 843 |
'screen' => 'property', |
| 844 |
'context' => 'normal', |
| 845 |
'priority' => 'high' |
| 846 |
); |
| 847 |
} |
| 848 |
|
| 849 |
$meta_boxes = apply_filters( 'propertyhive_property_marketing_meta_boxes', $meta_boxes ); |
| 850 |
ksort($meta_boxes); |
| 851 |
|
| 852 |
$ids = array(); |
| 853 |
foreach ($meta_boxes as $meta_box) |
| 854 |
{ |
| 855 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 856 |
$ids[] = $meta_box['id']; |
| 857 |
} |
| 858 |
|
| 859 |
$tabs['tab_marketing'] = array( |
| 860 |
'name' => __( 'Marketing', 'propertyhive' ), |
| 861 |
'metabox_ids' => $ids, |
| 862 |
'post_type' => 'property', |
| 863 |
); |
| 864 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'property' ) |
| 865 |
{ |
| 866 |
$tabs['tab_marketing']['ajax_actions'] = array( 'get_property_marketing_statistics_meta_box^' . wp_create_nonce( 'get_property_marketing_statistics_meta_box' ) . '^reload_marketing_statistics()' ); |
| 867 |
} |
| 868 |
|
| 869 |
/* PROPERTY DESCRIPTIONS META BOXES */ |
| 870 |
$meta_boxes = array(); |
| 871 |
$meta_boxes[5] = array( |
| 872 |
'id' => 'propertyhive-property-features', |
| 873 |
'title' => __( 'Property Features', 'propertyhive' ), |
| 874 |
'callback' => 'PH_Meta_Box_Property_Features::output', |
| 875 |
'screen' => 'property', |
| 876 |
'context' => 'normal', |
| 877 |
'priority' => 'high' |
| 878 |
); |
| 879 |
$meta_boxes[10] = array( |
| 880 |
'id' => 'postexcerpt', |
| 881 |
'title' => __( 'Property Summary Description', 'propertyhive' ), |
| 882 |
'callback' => 'PH_Meta_Box_Property_Summary_Description::output', |
| 883 |
'screen' => 'property', |
| 884 |
'context' => 'normal', |
| 885 |
'priority' => 'high' |
| 886 |
); |
| 887 |
$meta_boxes[15] = array( |
| 888 |
'id' => 'propertyhive-property-rooms', |
| 889 |
'title' => __( 'Property Descriptions', 'propertyhive' ), |
| 890 |
'callback' => 'PH_Meta_Box_Property_Rooms::output', |
| 891 |
'screen' => 'property', |
| 892 |
'context' => 'normal', |
| 893 |
'priority' => 'high' |
| 894 |
); |
| 895 |
$meta_boxes[20] = array( |
| 896 |
'id' => 'propertyhive-property-description', |
| 897 |
'title' => __( 'Property Description', 'propertyhive' ), |
| 898 |
'callback' => 'PH_Meta_Box_Property_Description::output', |
| 899 |
'screen' => 'property', |
| 900 |
'context' => 'normal', |
| 901 |
'priority' => 'high' |
| 902 |
); |
| 903 |
|
| 904 |
$meta_boxes = apply_filters( 'propertyhive_property_descriptions_meta_boxes', $meta_boxes ); |
| 905 |
ksort($meta_boxes); |
| 906 |
|
| 907 |
$ids = array(); |
| 908 |
foreach ($meta_boxes as $meta_box) |
| 909 |
{ |
| 910 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 911 |
$ids[] = $meta_box['id']; |
| 912 |
} |
| 913 |
|
| 914 |
$tabs['tab_descriptions'] = array( |
| 915 |
'name' => __( 'Descriptions', 'propertyhive' ), |
| 916 |
'metabox_ids' => $ids, |
| 917 |
'post_type' => 'property' |
| 918 |
); |
| 919 |
|
| 920 |
/* PROPERTY MEDIA META BOXES */ |
| 921 |
$meta_boxes = array(); |
| 922 |
$meta_boxes[5] = array( |
| 923 |
'id' => 'propertyhive-property-photos', |
| 924 |
'title' => __( 'Property Photos', 'propertyhive' ), |
| 925 |
'callback' => 'PH_Meta_Box_Property_Photos::output', |
| 926 |
'screen' => 'property', |
| 927 |
'context' => 'normal', |
| 928 |
'priority' => 'high' |
| 929 |
); |
| 930 |
$meta_boxes[10] = array( |
| 931 |
'id' => 'propertyhive-property-floorplans', |
| 932 |
'title' => __( 'Property Floorplans', 'propertyhive' ), |
| 933 |
'callback' => 'PH_Meta_Box_Property_Floorplans::output', |
| 934 |
'screen' => 'property', |
| 935 |
'context' => 'normal', |
| 936 |
'priority' => 'high' |
| 937 |
); |
| 938 |
$meta_boxes[15] = array( |
| 939 |
'id' => 'propertyhive-property-brochures', |
| 940 |
'title' => __( 'Property Brochures', 'propertyhive' ), |
| 941 |
'callback' => 'PH_Meta_Box_Property_Brochures::output', |
| 942 |
'screen' => 'property', |
| 943 |
'context' => 'normal', |
| 944 |
'priority' => 'high' |
| 945 |
); |
| 946 |
$meta_boxes[20] = array( |
| 947 |
'id' => 'propertyhive-property-epcs', |
| 948 |
'title' => __( 'Property EPCs', 'propertyhive' ), |
| 949 |
'callback' => 'PH_Meta_Box_Property_Epcs::output', |
| 950 |
'screen' => 'property', |
| 951 |
'context' => 'normal', |
| 952 |
'priority' => 'high' |
| 953 |
); |
| 954 |
$meta_boxes[25] = array( |
| 955 |
'id' => 'propertyhive-property-virtual-tours', |
| 956 |
'title' => __( 'Property Virtual Tours', 'propertyhive' ), |
| 957 |
'callback' => 'PH_Meta_Box_Property_Virtual_Tours::output', |
| 958 |
'screen' => 'property', |
| 959 |
'context' => 'normal', |
| 960 |
'priority' => 'high' |
| 961 |
); |
| 962 |
|
| 963 |
$meta_boxes = apply_filters( 'propertyhive_property_media_meta_boxes', $meta_boxes ); |
| 964 |
ksort($meta_boxes); |
| 965 |
|
| 966 |
$ids = array(); |
| 967 |
foreach ($meta_boxes as $meta_box) |
| 968 |
{ |
| 969 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 970 |
$ids[] = $meta_box['id']; |
| 971 |
} |
| 972 |
|
| 973 |
$tabs['tab_media'] = array( |
| 974 |
'name' => __( 'Media', 'propertyhive' ), |
| 975 |
'metabox_ids' => $ids, |
| 976 |
'post_type' => 'property' |
| 977 |
); |
| 978 |
|
| 979 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'property' ) |
| 980 |
{ |
| 981 |
/* PROPERTY VIEWINGS META BOXES */ |
| 982 |
if ( get_option('propertyhive_module_disabled_viewings', '') != 'yes' ) |
| 983 |
{ |
| 984 |
$meta_boxes = array(); |
| 985 |
$meta_boxes[5] = array( |
| 986 |
'id' => 'propertyhive-property-viewings', |
| 987 |
'title' => __( 'Viewings', 'propertyhive' ), |
| 988 |
'callback' => 'PH_Meta_Box_Property_Viewings::output', |
| 989 |
'screen' => 'property', |
| 990 |
'context' => 'normal', |
| 991 |
'priority' => 'high' |
| 992 |
); |
| 993 |
|
| 994 |
$meta_boxes = apply_filters( 'propertyhive_property_viewings_meta_boxes', $meta_boxes ); |
| 995 |
ksort($meta_boxes); |
| 996 |
|
| 997 |
$ids = array(); |
| 998 |
foreach ($meta_boxes as $meta_box) |
| 999 |
{ |
| 1000 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 1001 |
$ids[] = $meta_box['id']; |
| 1002 |
} |
| 1003 |
|
| 1004 |
$tab_name_suffix = ''; |
| 1005 |
if ( apply_filters( 'propertyhive_show_tab_counts', true ) === true ) |
| 1006 |
{ |
| 1007 |
$args = array( |
| 1008 |
'post_type' => 'viewing', |
| 1009 |
'nopaging' => true, |
| 1010 |
'fields' => 'ids', |
| 1011 |
'post_status' => 'publish', |
| 1012 |
'meta_query' => array( |
| 1013 |
array( |
| 1014 |
'key' => '_property_id', |
| 1015 |
'value' => $post->ID |
| 1016 |
), |
| 1017 |
), |
| 1018 |
); |
| 1019 |
$viewings_query = new WP_Query( $args ); |
| 1020 |
$viewings_count = $viewings_query->found_posts; |
| 1021 |
wp_reset_postdata(); |
| 1022 |
|
| 1023 |
$tab_name_suffix = ' (' . $viewings_count . ')'; |
| 1024 |
} |
| 1025 |
|
| 1026 |
$tabs['tab_viewings'] = array( |
| 1027 |
'name' => __( 'Viewings', 'propertyhive' ) . $tab_name_suffix, |
| 1028 |
'metabox_ids' => $ids, |
| 1029 |
'post_type' => 'property', |
| 1030 |
'ajax_actions' => array( 'get_property_viewings_meta_box' ), |
| 1031 |
); |
| 1032 |
} |
| 1033 |
|
| 1034 |
if ( get_option('propertyhive_module_disabled_offers_sales', '') != 'yes' ) |
| 1035 |
{ |
| 1036 |
if ( |
| 1037 |
( |
| 1038 |
get_post_meta( $post->ID, '_department', TRUE ) == 'residential-sales' || |
| 1039 |
ph_get_custom_department_based_on(get_post_meta( $post->ID, '_department', TRUE )) == 'residential-sales' |
| 1040 |
) |
| 1041 |
|| |
| 1042 |
( |
| 1043 |
( |
| 1044 |
get_post_meta( $post->ID, '_department', TRUE ) == 'commercial' || |
| 1045 |
ph_get_custom_department_based_on(get_post_meta( $post->ID, '_department', TRUE )) == 'commercial' |
| 1046 |
) |
| 1047 |
&& |
| 1048 |
get_post_meta( $post->ID, '_for_sale', TRUE ) == 'yes' |
| 1049 |
) |
| 1050 |
) |
| 1051 |
{ |
| 1052 |
/* PROPERTY OFFERS META BOXES */ |
| 1053 |
$meta_boxes = array(); |
| 1054 |
$meta_boxes[5] = array( |
| 1055 |
'id' => 'propertyhive-property-offers', |
| 1056 |
'title' => __( 'Offers', 'propertyhive' ), |
| 1057 |
'callback' => 'PH_Meta_Box_Property_Offers::output', |
| 1058 |
'screen' => 'property', |
| 1059 |
'context' => 'normal', |
| 1060 |
'priority' => 'high' |
| 1061 |
); |
| 1062 |
|
| 1063 |
$meta_boxes = apply_filters( 'propertyhive_property_offers_meta_boxes', $meta_boxes ); |
| 1064 |
ksort($meta_boxes); |
| 1065 |
|
| 1066 |
$ids = array(); |
| 1067 |
foreach ($meta_boxes as $meta_box) |
| 1068 |
{ |
| 1069 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 1070 |
$ids[] = $meta_box['id']; |
| 1071 |
} |
| 1072 |
|
| 1073 |
$tab_name_suffix = ''; |
| 1074 |
if ( apply_filters( 'propertyhive_show_tab_counts', true ) === true ) |
| 1075 |
{ |
| 1076 |
$args = array( |
| 1077 |
'post_type' => 'offer', |
| 1078 |
'nopaging' => true, |
| 1079 |
'fields' => 'ids', |
| 1080 |
'post_status' => 'publish', |
| 1081 |
'meta_query' => array( |
| 1082 |
array( |
| 1083 |
'key' => '_property_id', |
| 1084 |
'value' => $post->ID |
| 1085 |
), |
| 1086 |
), |
| 1087 |
); |
| 1088 |
$offers_query = new WP_Query( $args ); |
| 1089 |
$offers_count = $offers_query->found_posts; |
| 1090 |
wp_reset_postdata(); |
| 1091 |
|
| 1092 |
$tab_name_suffix = ' (' . $offers_count . ')'; |
| 1093 |
} |
| 1094 |
|
| 1095 |
$tabs['tab_offers'] = array( |
| 1096 |
'name' => __( 'Offers', 'propertyhive' ) . $tab_name_suffix, |
| 1097 |
'metabox_ids' => $ids, |
| 1098 |
'post_type' => 'property', |
| 1099 |
'ajax_actions' => array( 'get_property_offers_meta_box' ), |
| 1100 |
); |
| 1101 |
|
| 1102 |
/* PROPERTY SALES META BOXES */ |
| 1103 |
$meta_boxes = array(); |
| 1104 |
$meta_boxes[5] = array( |
| 1105 |
'id' => 'propertyhive-property-sales', |
| 1106 |
'title' => __( 'Sales', 'propertyhive' ), |
| 1107 |
'callback' => 'PH_Meta_Box_Property_Sales::output', |
| 1108 |
'screen' => 'property', |
| 1109 |
'context' => 'normal', |
| 1110 |
'priority' => 'high' |
| 1111 |
); |
| 1112 |
|
| 1113 |
$meta_boxes = apply_filters( 'propertyhive_property_sales_meta_boxes', $meta_boxes ); |
| 1114 |
ksort($meta_boxes); |
| 1115 |
|
| 1116 |
$ids = array(); |
| 1117 |
foreach ($meta_boxes as $meta_box) |
| 1118 |
{ |
| 1119 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 1120 |
$ids[] = $meta_box['id']; |
| 1121 |
} |
| 1122 |
|
| 1123 |
$tab_name_suffix = ''; |
| 1124 |
if ( apply_filters( 'propertyhive_show_tab_counts', true ) === true ) |
| 1125 |
{ |
| 1126 |
$args = array( |
| 1127 |
'post_type' => 'sale', |
| 1128 |
'nopaging' => true, |
| 1129 |
'fields' => 'ids', |
| 1130 |
'post_status' => 'publish', |
| 1131 |
'meta_query' => array( |
| 1132 |
array( |
| 1133 |
'key' => '_property_id', |
| 1134 |
'value' => $post->ID |
| 1135 |
), |
| 1136 |
), |
| 1137 |
); |
| 1138 |
$sales_query = new WP_Query( $args ); |
| 1139 |
$sales_count = $sales_query->found_posts; |
| 1140 |
wp_reset_postdata(); |
| 1141 |
|
| 1142 |
$tab_name_suffix = ' (' . $sales_count . ')'; |
| 1143 |
} |
| 1144 |
|
| 1145 |
$tabs['tab_sales'] = array( |
| 1146 |
'name' => __( 'Sales', 'propertyhive' ) . $tab_name_suffix, |
| 1147 |
'metabox_ids' => $ids, |
| 1148 |
'post_type' => 'property', |
| 1149 |
'ajax_actions' => array( 'get_property_sales_meta_box' ), |
| 1150 |
); |
| 1151 |
} |
| 1152 |
} |
| 1153 |
} |
| 1154 |
|
| 1155 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'property' ) |
| 1156 |
{ |
| 1157 |
if ( get_option('propertyhive_module_disabled_enquiries', '') != 'yes' ) |
| 1158 |
{ |
| 1159 |
/* PROPERTY ENQUIRIES META BOXES */ |
| 1160 |
$meta_boxes = array(); |
| 1161 |
$meta_boxes[5] = array( |
| 1162 |
'id' => 'propertyhive-property-enquiries', |
| 1163 |
'title' => __( 'Enquiries', 'propertyhive' ), |
| 1164 |
'callback' => 'PH_Meta_Box_Property_Enquiries::output', |
| 1165 |
'screen' => 'property', |
| 1166 |
'context' => 'normal', |
| 1167 |
'priority' => 'high' |
| 1168 |
); |
| 1169 |
|
| 1170 |
$meta_boxes = apply_filters( 'propertyhive_property_enquiries_meta_boxes', $meta_boxes ); |
| 1171 |
ksort($meta_boxes); |
| 1172 |
|
| 1173 |
$ids = array(); |
| 1174 |
foreach ($meta_boxes as $meta_box) |
| 1175 |
{ |
| 1176 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 1177 |
$ids[] = $meta_box['id']; |
| 1178 |
} |
| 1179 |
|
| 1180 |
$tab_name_suffix = ''; |
| 1181 |
if ( apply_filters( 'propertyhive_show_tab_counts', true ) === true ) |
| 1182 |
{ |
| 1183 |
$args = array( |
| 1184 |
'post_type' => 'enquiry', |
| 1185 |
'nopaging' => true, |
| 1186 |
'fields' => 'ids', |
| 1187 |
'meta_query' => array( |
| 1188 |
'relation' => 'OR', |
| 1189 |
array( |
| 1190 |
'key' => 'property_id', |
| 1191 |
'value' => $post->ID |
| 1192 |
), |
| 1193 |
array( |
| 1194 |
'key' => '_property_id', |
| 1195 |
'value' => $post->ID |
| 1196 |
) |
| 1197 |
), |
| 1198 |
); |
| 1199 |
$enquiry_query = new WP_Query( $args ); |
| 1200 |
$enquiry_count = $enquiry_query->found_posts; |
| 1201 |
wp_reset_postdata(); |
| 1202 |
|
| 1203 |
$tab_name_suffix = ' (' . $enquiry_count . ')'; |
| 1204 |
} |
| 1205 |
|
| 1206 |
$tabs['tab_enquiries'] = array( |
| 1207 |
'name' => __( 'Enquiries', 'propertyhive' ) . $tab_name_suffix, |
| 1208 |
'metabox_ids' => $ids, |
| 1209 |
'post_type' => 'property', |
| 1210 |
'ajax_actions' => array( 'get_property_enquiries_meta_box' ), |
| 1211 |
); |
| 1212 |
} |
| 1213 |
} |
| 1214 |
|
| 1215 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'property' ) { |
| 1216 |
|
| 1217 |
if ( |
| 1218 |
get_post_meta( $post->ID, '_department', TRUE ) == 'residential-lettings' || |
| 1219 |
ph_get_custom_department_based_on(get_post_meta( $post->ID, '_department', TRUE )) == 'residential-lettings' |
| 1220 |
) |
| 1221 |
{ |
| 1222 |
if ( get_option( 'propertyhive_module_disabled_tenancies', '' ) != 'yes' ) |
| 1223 |
{ |
| 1224 |
/* TENANCY MANAGEMENT META BOXES */ |
| 1225 |
$meta_boxes = array(); |
| 1226 |
|
| 1227 |
$meta_boxes[5] = array( |
| 1228 |
'id' => 'propertyhive-property-tenancies', |
| 1229 |
'title' => __( 'Tenancies', 'propertyhive' ), |
| 1230 |
'callback' => 'PH_Meta_Box_Property_Tenancies::output', |
| 1231 |
'screen' => 'property', |
| 1232 |
'context' => 'normal', |
| 1233 |
'priority' => 'high' |
| 1234 |
); |
| 1235 |
|
| 1236 |
$meta_boxes[10] = array( |
| 1237 |
'id' => 'propertyhive-management-dates', |
| 1238 |
'title' => __( 'Management Dates', 'propertyhive' ), |
| 1239 |
'callback' => 'PH_Meta_Box_Management_Dates::output', |
| 1240 |
'screen' => 'property', |
| 1241 |
'context' => 'normal', |
| 1242 |
'priority' => 'high' |
| 1243 |
); |
| 1244 |
|
| 1245 |
$meta_boxes = apply_filters( 'propertyhive_property_management_meta_boxes', $meta_boxes ); |
| 1246 |
ksort( $meta_boxes ); |
| 1247 |
|
| 1248 |
$ids = array(); |
| 1249 |
foreach ( $meta_boxes as $meta_box ) { |
| 1250 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 1251 |
$ids[] = $meta_box['id']; |
| 1252 |
} |
| 1253 |
|
| 1254 |
$tabs['tab_property_management'] = array( |
| 1255 |
'name' => __( 'Management', 'propertyhive' ), |
| 1256 |
'metabox_ids' => $ids, |
| 1257 |
'post_type' => 'property', |
| 1258 |
'ajax_actions' => array( 'get_property_tenancies_grid^' . wp_create_nonce( 'get_property_tenancies_grid' ) ), |
| 1259 |
); |
| 1260 |
} |
| 1261 |
} |
| 1262 |
} |
| 1263 |
|
| 1264 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'property' ) |
| 1265 |
{ |
| 1266 |
/* PROPERTY NOTES META BOXES */ |
| 1267 |
$meta_boxes = array(); |
| 1268 |
$meta_boxes[5] = array( |
| 1269 |
'id' => 'propertyhive-property-history-notes', |
| 1270 |
'title' => __( 'Property History & Notes', 'propertyhive' ), |
| 1271 |
'callback' => 'PH_Meta_Box_Property_Notes::output', |
| 1272 |
'screen' => 'property', |
| 1273 |
'context' => 'normal', |
| 1274 |
'priority' => 'high' |
| 1275 |
); |
| 1276 |
|
| 1277 |
$meta_boxes = apply_filters( 'propertyhive_property_notes_meta_boxes', $meta_boxes ); |
| 1278 |
ksort($meta_boxes); |
| 1279 |
|
| 1280 |
$ids = array(); |
| 1281 |
foreach ($meta_boxes as $meta_box) |
| 1282 |
{ |
| 1283 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 1284 |
$ids[] = $meta_box['id']; |
| 1285 |
} |
| 1286 |
|
| 1287 |
$tabs['tab_property_notes'] = array( |
| 1288 |
'name' => __( 'History & Notes', 'propertyhive' ), |
| 1289 |
'metabox_ids' => $ids, |
| 1290 |
'post_type' => 'property', |
| 1291 |
'ajax_actions' => array( '^^ph_redraw_notes_grid(\'property\')' ), |
| 1292 |
); |
| 1293 |
|
| 1294 |
add_meta_box( 'propertyhive-property-actions', __( 'Actions', 'propertyhive' ), 'PH_Meta_Box_Property_Actions::output', 'property', 'side' ); |
| 1295 |
} |
| 1296 |
|
| 1297 |
// CONTACT |
| 1298 |
if (!isset($tabs)) $tabs = array(); |
| 1299 |
|
| 1300 |
$meta_boxes = array(); |
| 1301 |
|
| 1302 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'contact' ) |
| 1303 |
{ |
| 1304 |
if ( !empty($pinned_notes) ) |
| 1305 |
{ |
| 1306 |
$meta_boxes[1] = array( |
| 1307 |
'id' => 'propertyhive-contact-pinned-notes', |
| 1308 |
'title' => __( 'Pinned Notes', 'propertyhive' ), |
| 1309 |
'callback' => 'PH_Meta_Box_Contact_Pinned_Notes::output', |
| 1310 |
'screen' => 'contact', |
| 1311 |
'context' => 'normal', |
| 1312 |
'priority' => 'high', |
| 1313 |
); |
| 1314 |
} |
| 1315 |
} |
| 1316 |
if ( $pagenow == 'post-new.php' && get_post_type($post->ID) == 'contact' ) |
| 1317 |
{ |
| 1318 |
$meta_boxes[2] = array( |
| 1319 |
'id' => 'propertyhive-contact-new-relationship', |
| 1320 |
'title' => __( 'Contact Type', 'propertyhive' ), |
| 1321 |
'callback' => 'PH_Meta_Box_Contact_New_Relationship::output', |
| 1322 |
'screen' => 'contact', |
| 1323 |
'context' => 'normal', |
| 1324 |
'priority' => 'high' |
| 1325 |
); |
| 1326 |
} |
| 1327 |
|
| 1328 |
$meta_boxes[5] = array( |
| 1329 |
'id' => 'propertyhive-contact-correspondence-address', |
| 1330 |
'title' => __( 'Correspondence Address', 'propertyhive' ), |
| 1331 |
'callback' => 'PH_Meta_Box_Contact_Correspondence_Address::output', |
| 1332 |
'screen' => 'contact', |
| 1333 |
'context' => 'normal', |
| 1334 |
'priority' => 'high' |
| 1335 |
); |
| 1336 |
$meta_boxes[10] = array( |
| 1337 |
'id' => 'propertyhive-contact-contact-details', |
| 1338 |
'title' => __( 'Contact Details', 'propertyhive' ), |
| 1339 |
'callback' => 'PH_Meta_Box_Contact_Contact_Details::output', |
| 1340 |
'screen' => 'contact', |
| 1341 |
'context' => 'normal', |
| 1342 |
'priority' => 'high' |
| 1343 |
); |
| 1344 |
$meta_boxes[15] = array( |
| 1345 |
'id' => 'propertyhive-contact-solicitor', |
| 1346 |
'title' => __( 'Contact Solicitor Details', 'propertyhive' ), |
| 1347 |
'callback' => 'PH_Meta_Box_Contact_Solicitor::output', |
| 1348 |
'screen' => 'contact', |
| 1349 |
'context' => 'normal', |
| 1350 |
'priority' => 'high' |
| 1351 |
); |
| 1352 |
|
| 1353 |
$meta_boxes = apply_filters( 'propertyhive_contact_details_meta_boxes', $meta_boxes ); |
| 1354 |
ksort($meta_boxes); |
| 1355 |
|
| 1356 |
$ids = array(); |
| 1357 |
foreach ($meta_boxes as $meta_box) |
| 1358 |
{ |
| 1359 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 1360 |
$ids[] = $meta_box['id']; |
| 1361 |
} |
| 1362 |
|
| 1363 |
$tabs['tab_contact_details'] = array( |
| 1364 |
'name' => __( 'Contact Details', 'propertyhive' ), |
| 1365 |
'metabox_ids' => $ids, |
| 1366 |
'post_type' => 'contact' |
| 1367 |
); |
| 1368 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'contact' ) |
| 1369 |
{ |
| 1370 |
$tabs['tab_contact_details']['ajax_actions'] = array( '^^ph_redraw_pinned_notes_grid(\'contact\')' ); |
| 1371 |
} |
| 1372 |
|
| 1373 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'contact' ) |
| 1374 |
{ |
| 1375 |
add_meta_box( 'propertyhive-contact-relationships', __( 'Relationships', 'propertyhive' ), 'PH_Meta_Box_Contact_Relationships::output', 'contact', 'normal', 'high' ); |
| 1376 |
$tabs['tab_contact_relationships'] = array( |
| 1377 |
'name' => __( 'Relationships', 'propertyhive' ), |
| 1378 |
'metabox_ids' => array('propertyhive-contact-relationships'), |
| 1379 |
'post_type' => 'contact' |
| 1380 |
); |
| 1381 |
} |
| 1382 |
|
| 1383 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'contact' ) |
| 1384 |
{ |
| 1385 |
$contact_types = get_post_meta( $post->ID, '_contact_types', TRUE ); |
| 1386 |
|
| 1387 |
if ( get_option('propertyhive_module_disabled_viewings', '') != 'yes' ) |
| 1388 |
{ |
| 1389 |
$args = array( |
| 1390 |
'post_type' => 'viewing', |
| 1391 |
'posts_per_page' => 1, |
| 1392 |
'fields' => 'ids', |
| 1393 |
'meta_query' => array( |
| 1394 |
array( |
| 1395 |
'key' => '_applicant_contact_id', |
| 1396 |
'value' => $post->ID |
| 1397 |
) |
| 1398 |
) |
| 1399 |
); |
| 1400 |
$viewing_query = new WP_Query( $args ); |
| 1401 |
$viewing_count = $viewing_query->found_posts; |
| 1402 |
wp_reset_postdata(); |
| 1403 |
|
| 1404 |
// If contact is an applicant, or is attached to a viewing, show the viewings tab and meta box |
| 1405 |
if ( |
| 1406 |
( is_array($contact_types) && in_array('applicant', $contact_types) ) |
| 1407 |
|| |
| 1408 |
$viewing_count > 0 |
| 1409 |
) |
| 1410 |
{ |
| 1411 |
/* CONTACT VIEWINGS META BOXES */ |
| 1412 |
add_meta_box( 'propertyhive-contact-viewings', __( 'Viewings', 'propertyhive' ), 'PH_Meta_Box_Contact_Viewings::output', 'contact', 'normal', 'high' ); |
| 1413 |
|
| 1414 |
$tab_name_suffix = ''; |
| 1415 |
if ( apply_filters( 'propertyhive_show_tab_counts', true ) === true ) |
| 1416 |
{ |
| 1417 |
$tab_name_suffix = ' (' . $viewing_count . ')'; |
| 1418 |
} |
| 1419 |
|
| 1420 |
$tabs['tab_viewings'] = array( |
| 1421 |
'name' => __( 'Viewings', 'propertyhive' ) . $tab_name_suffix, |
| 1422 |
'metabox_ids' => array('propertyhive-contact-viewings'), |
| 1423 |
'post_type' => 'contact', |
| 1424 |
'ajax_actions' => array( 'get_contact_viewings_meta_box' ), |
| 1425 |
); |
| 1426 |
} |
| 1427 |
} |
| 1428 |
|
| 1429 |
if ( get_option('propertyhive_module_disabled_offers_sales', '') != 'yes' ) |
| 1430 |
{ |
| 1431 |
$args = array( |
| 1432 |
'post_type' => 'offer', |
| 1433 |
'posts_per_page' => 1, |
| 1434 |
'fields' => 'ids', |
| 1435 |
'meta_query' => array( |
| 1436 |
array( |
| 1437 |
'key' => '_applicant_contact_id', |
| 1438 |
'value' => $post->ID |
| 1439 |
) |
| 1440 |
) |
| 1441 |
); |
| 1442 |
$offer_query = new WP_Query( $args ); |
| 1443 |
$offer_count = $offer_query->found_posts; |
| 1444 |
wp_reset_postdata(); |
| 1445 |
|
| 1446 |
$args = array( |
| 1447 |
'post_type' => 'sale', |
| 1448 |
'posts_per_page' => 1, |
| 1449 |
'fields' => 'ids', |
| 1450 |
'meta_query' => array( |
| 1451 |
array( |
| 1452 |
'key' => '_applicant_contact_id', |
| 1453 |
'value' => $post->ID |
| 1454 |
) |
| 1455 |
) |
| 1456 |
); |
| 1457 |
$sale_query = new WP_Query( $args ); |
| 1458 |
$sale_count = $sale_query->found_posts; |
| 1459 |
wp_reset_postdata(); |
| 1460 |
|
| 1461 |
$has_sales_applicant_profile = false; |
| 1462 |
if ( $offer_count == 0 || $sale_count == 0 ) |
| 1463 |
{ |
| 1464 |
if ( is_array($contact_types) && in_array('applicant', $contact_types) ) |
| 1465 |
{ |
| 1466 |
$num_applicant_profiles = get_post_meta( $post->ID, '_applicant_profiles', TRUE ); |
| 1467 |
if ( $num_applicant_profiles == '' ) |
| 1468 |
{ |
| 1469 |
$num_applicant_profiles = 0; |
| 1470 |
} |
| 1471 |
|
| 1472 |
if ( $num_applicant_profiles > 0 ) |
| 1473 |
{ |
| 1474 |
for ( $i = 0; $i < $num_applicant_profiles; ++$i ) |
| 1475 |
{ |
| 1476 |
$applicant_profile = get_post_meta( $post->ID, '_applicant_profile_' . $i, TRUE ); |
| 1477 |
|
| 1478 |
if ( |
| 1479 |
isset($applicant_profile['department']) && |
| 1480 |
( |
| 1481 |
$applicant_profile['department'] == 'residential-sales' || |
| 1482 |
ph_get_custom_department_based_on($applicant_profile['department']) == 'residential-sales' |
| 1483 |
) |
| 1484 |
) |
| 1485 |
{ |
| 1486 |
$has_sales_applicant_profile = true; |
| 1487 |
} |
| 1488 |
} |
| 1489 |
} |
| 1490 |
} |
| 1491 |
} |
| 1492 |
|
| 1493 |
if ( $has_sales_applicant_profile === true || $offer_count > 0 ) |
| 1494 |
{ |
| 1495 |
/* CONTACT OFFERS META BOXES */ |
| 1496 |
add_meta_box( 'propertyhive-contact-offers', __( 'Offers', 'propertyhive' ), 'PH_Meta_Box_Contact_Offers::output', 'contact', 'normal', 'high' ); |
| 1497 |
|
| 1498 |
$tab_name_suffix = ''; |
| 1499 |
if ( apply_filters( 'propertyhive_show_tab_counts', true ) === true ) |
| 1500 |
{ |
| 1501 |
$tab_name_suffix = ' (' . $offer_count . ')'; |
| 1502 |
} |
| 1503 |
|
| 1504 |
$tabs['tab_offers'] = array( |
| 1505 |
'name' => __( 'Offers', 'propertyhive' ) . $tab_name_suffix, |
| 1506 |
'metabox_ids' => array('propertyhive-contact-offers'), |
| 1507 |
'post_type' => 'contact', |
| 1508 |
'ajax_actions' => array( 'get_contact_offers_meta_box' ), |
| 1509 |
); |
| 1510 |
} |
| 1511 |
|
| 1512 |
if ( $has_sales_applicant_profile === true || $sale_count > 0 ) |
| 1513 |
{ |
| 1514 |
/* CONTACT SALES META BOXES */ |
| 1515 |
add_meta_box( 'propertyhive-contact-sales', __( 'Sales', 'propertyhive' ), 'PH_Meta_Box_Contact_Sales::output', 'contact', 'normal', 'high' ); |
| 1516 |
|
| 1517 |
$tab_name_suffix = ''; |
| 1518 |
if ( apply_filters( 'propertyhive_show_tab_counts', true ) === true ) |
| 1519 |
{ |
| 1520 |
$tab_name_suffix = ' (' . $sale_count . ')'; |
| 1521 |
} |
| 1522 |
|
| 1523 |
$tabs['tab_sales'] = array( |
| 1524 |
'name' => __( 'Sales', 'propertyhive' ) . $tab_name_suffix, |
| 1525 |
'metabox_ids' => array('propertyhive-contact-sales'), |
| 1526 |
'post_type' => 'contact', |
| 1527 |
'ajax_actions' => array( 'get_contact_sales_meta_box' ), |
| 1528 |
); |
| 1529 |
} |
| 1530 |
} |
| 1531 |
|
| 1532 |
if ( get_option( 'propertyhive_module_disabled_tenancies', '' ) != 'yes' ) |
| 1533 |
{ |
| 1534 |
$args = array( |
| 1535 |
'post_type' => 'tenancy', |
| 1536 |
'posts_per_page' => 1, |
| 1537 |
'fields' => 'ids', |
| 1538 |
'meta_query' => array( |
| 1539 |
array( |
| 1540 |
'key' => '_applicant_contact_id', |
| 1541 |
'value' => $post->ID |
| 1542 |
) |
| 1543 |
) |
| 1544 |
); |
| 1545 |
$tenancy_query = new WP_Query( $args ); |
| 1546 |
$tenancy_count = $tenancy_query->found_posts; |
| 1547 |
wp_reset_postdata(); |
| 1548 |
|
| 1549 |
$has_lettings_applicant_profile = false; |
| 1550 |
if ( $tenancy_count == 0 ) |
| 1551 |
{ |
| 1552 |
if ( is_array($contact_types) && in_array('applicant', $contact_types) ) |
| 1553 |
{ |
| 1554 |
$num_applicant_profiles = get_post_meta( $post->ID, '_applicant_profiles', TRUE ); |
| 1555 |
if ( $num_applicant_profiles == '' ) |
| 1556 |
{ |
| 1557 |
$num_applicant_profiles = 0; |
| 1558 |
} |
| 1559 |
|
| 1560 |
if ( $num_applicant_profiles > 0 ) |
| 1561 |
{ |
| 1562 |
for ( $i = 0; $i < $num_applicant_profiles; ++$i ) |
| 1563 |
{ |
| 1564 |
$applicant_profile = get_post_meta( $post->ID, '_applicant_profile_' . $i, TRUE ); |
| 1565 |
|
| 1566 |
if ( |
| 1567 |
isset($applicant_profile['department']) && |
| 1568 |
( |
| 1569 |
$applicant_profile['department'] == 'residential-lettings' || |
| 1570 |
ph_get_custom_department_based_on($applicant_profile['department']) == 'residential-lettings' |
| 1571 |
) |
| 1572 |
) |
| 1573 |
{ |
| 1574 |
$has_lettings_applicant_profile = true; |
| 1575 |
} |
| 1576 |
} |
| 1577 |
} |
| 1578 |
} |
| 1579 |
} |
| 1580 |
|
| 1581 |
if ( $has_lettings_applicant_profile === true || $tenancy_count > 0 ) |
| 1582 |
{ |
| 1583 |
$meta_boxes = array(); |
| 1584 |
|
| 1585 |
$meta_boxes[5] = array( |
| 1586 |
'id' => 'propertyhive-contact-tenancies', |
| 1587 |
'title' => __( 'Tenancies', 'propertyhive' ), |
| 1588 |
'callback' => 'PH_Meta_Box_Contact_Tenancies::output', |
| 1589 |
'screen' => 'contact', |
| 1590 |
'context' => 'normal', |
| 1591 |
'priority' => 'high' |
| 1592 |
); |
| 1593 |
|
| 1594 |
$meta_boxes = apply_filters( 'propertyhive_contact_tenancies_meta_boxes', $meta_boxes ); |
| 1595 |
ksort( $meta_boxes ); |
| 1596 |
|
| 1597 |
$ids = array(); |
| 1598 |
foreach ( $meta_boxes as $meta_box ) { |
| 1599 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 1600 |
$ids[] = $meta_box['id']; |
| 1601 |
} |
| 1602 |
|
| 1603 |
$tab_name_suffix = ''; |
| 1604 |
if ( apply_filters( 'propertyhive_show_tab_counts', true ) === true ) |
| 1605 |
{ |
| 1606 |
$tab_name_suffix = ' (' . $tenancy_count . ')'; |
| 1607 |
} |
| 1608 |
|
| 1609 |
$tabs['tab_contact_tenancies'] = array( |
| 1610 |
'name' => __( 'Tenancies', 'propertyhive' ) . $tab_name_suffix, |
| 1611 |
'metabox_ids' => $ids, |
| 1612 |
'post_type' => 'contact', |
| 1613 |
'ajax_actions' => array( 'get_contact_tenancies_grid^' . wp_create_nonce( 'get_contact_tenancies_grid' ) ), |
| 1614 |
); |
| 1615 |
} |
| 1616 |
} |
| 1617 |
|
| 1618 |
if ( get_option('propertyhive_module_disabled_enquiries', '') != 'yes' ) |
| 1619 |
{ |
| 1620 |
$meta_query = array( |
| 1621 |
'relation' => 'OR', |
| 1622 |
array( |
| 1623 |
'key' => '_contact_id', |
| 1624 |
'value' => $post->ID, |
| 1625 |
), |
| 1626 |
); |
| 1627 |
|
| 1628 |
$contact_email_address = get_post_meta( $post->ID, '_email_address', TRUE ); |
| 1629 |
if ( !empty($contact_email_address) ) |
| 1630 |
{ |
| 1631 |
$meta_query[] = array( |
| 1632 |
'key' => 'email', |
| 1633 |
'value' => $contact_email_address, |
| 1634 |
); |
| 1635 |
|
| 1636 |
$meta_query[] = array( |
| 1637 |
'key' => 'email_address', |
| 1638 |
'value' => $contact_email_address, |
| 1639 |
); |
| 1640 |
} |
| 1641 |
|
| 1642 |
$tab_name_suffix = ''; |
| 1643 |
if ( apply_filters( 'propertyhive_show_tab_counts', true ) === true ) |
| 1644 |
{ |
| 1645 |
$args = array( |
| 1646 |
'post_type' => 'enquiry', |
| 1647 |
'nopaging' => true, |
| 1648 |
'fields' => 'ids', |
| 1649 |
'meta_query' => $meta_query, |
| 1650 |
); |
| 1651 |
$enquiry_query = new WP_Query( $args ); |
| 1652 |
$enquiry_count = $enquiry_query->found_posts; |
| 1653 |
|
| 1654 |
$tab_name_suffix = ' (' . $enquiry_count . ')'; |
| 1655 |
} |
| 1656 |
|
| 1657 |
wp_reset_postdata(); |
| 1658 |
|
| 1659 |
/* CONTACT ENQUIRIES META BOXES */ |
| 1660 |
add_meta_box( 'propertyhive-contact-enquiries', __( 'Enquiries', 'propertyhive' ), 'PH_Meta_Box_Contact_Enquiries::output', 'contact', 'normal', 'high' ); |
| 1661 |
$tabs['tab_contact_enquiries'] = array( |
| 1662 |
'name' => __( 'Enquiries', 'propertyhive' ) . $tab_name_suffix, |
| 1663 |
'metabox_ids' => array('propertyhive-contact-enquiries'), |
| 1664 |
'post_type' => 'contact', |
| 1665 |
'ajax_actions' => array( 'get_contact_enquiries_meta_box' ), |
| 1666 |
); |
| 1667 |
} |
| 1668 |
|
| 1669 |
$meta_boxes = array(); |
| 1670 |
$meta_boxes[5] = array( |
| 1671 |
'id' => 'propertyhive-contact-history-notes', |
| 1672 |
'title' => __( 'Contact History & Notes', 'propertyhive' ), |
| 1673 |
'callback' => 'PH_Meta_Box_Contact_Notes::output', |
| 1674 |
'screen' => 'contact', |
| 1675 |
'context' => 'normal', |
| 1676 |
'priority' => 'high' |
| 1677 |
); |
| 1678 |
|
| 1679 |
$meta_boxes = apply_filters( 'propertyhive_contact_notes_meta_boxes', $meta_boxes ); |
| 1680 |
ksort($meta_boxes); |
| 1681 |
|
| 1682 |
$ids = array(); |
| 1683 |
foreach ($meta_boxes as $meta_box) |
| 1684 |
{ |
| 1685 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 1686 |
$ids[] = $meta_box['id']; |
| 1687 |
} |
| 1688 |
|
| 1689 |
$tabs['tab_contact_notes'] = array( |
| 1690 |
'name' => __( 'History & Notes', 'propertyhive' ), |
| 1691 |
'metabox_ids' => $ids, |
| 1692 |
'post_type' => 'contact', |
| 1693 |
'ajax_actions' => array( '^^ph_redraw_notes_grid(\'contact\')' ), |
| 1694 |
); |
| 1695 |
|
| 1696 |
add_meta_box( 'propertyhive-contact-actions', __( 'Actions', 'propertyhive' ), 'PH_Meta_Box_Contact_Actions::output', 'contact', 'side' ); |
| 1697 |
} |
| 1698 |
|
| 1699 |
// ENQUIRY |
| 1700 |
if (!isset($tabs)) $tabs = array(); |
| 1701 |
|
| 1702 |
$meta_boxes = array(); |
| 1703 |
|
| 1704 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'enquiry' ) |
| 1705 |
{ |
| 1706 |
if ( !empty($pinned_notes) ) |
| 1707 |
{ |
| 1708 |
$meta_boxes[1] = array( |
| 1709 |
'id' => 'propertyhive-enquiry-pinned-notes', |
| 1710 |
'title' => __( 'Pinned Notes', 'propertyhive' ), |
| 1711 |
'callback' => 'PH_Meta_Box_Enquiry_Pinned_Notes::output', |
| 1712 |
'screen' => 'enquiry', |
| 1713 |
'context' => 'normal', |
| 1714 |
'priority' => 'high', |
| 1715 |
); |
| 1716 |
} |
| 1717 |
} |
| 1718 |
$meta_boxes[5] = array( |
| 1719 |
'id' => 'propertyhive-enquiry-record-details', |
| 1720 |
'title' => __( 'Record Details', 'propertyhive' ), |
| 1721 |
'callback' => 'PH_Meta_Box_Enquiry_Record_details::output', |
| 1722 |
'screen' => 'enquiry', |
| 1723 |
'context' => 'normal', |
| 1724 |
'priority' => 'high' |
| 1725 |
); |
| 1726 |
$meta_boxes[10] = array( |
| 1727 |
'id' => 'propertyhive-enquiry-details', |
| 1728 |
'title' => __( 'Enquiry Details', 'propertyhive' ), |
| 1729 |
'callback' => 'PH_Meta_Box_Enquiry_Details::output', |
| 1730 |
'screen' => 'enquiry', |
| 1731 |
'context' => 'normal', |
| 1732 |
'priority' => 'high' |
| 1733 |
); |
| 1734 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'enquiry' ) |
| 1735 |
{ |
| 1736 |
$meta_boxes[15] = array( |
| 1737 |
'id' => 'propertyhive-enquiry-lead-tracking', |
| 1738 |
'title' => __( 'Lead Tracking', 'propertyhive' ), |
| 1739 |
'callback' => 'PH_Meta_Box_Enquiry_Lead_Tracking::output', |
| 1740 |
'screen' => 'enquiry', |
| 1741 |
'context' => 'normal', |
| 1742 |
'priority' => 'high' |
| 1743 |
); |
| 1744 |
} |
| 1745 |
|
| 1746 |
$meta_boxes = apply_filters( 'propertyhive_enquiry_details_meta_boxes', $meta_boxes ); |
| 1747 |
ksort($meta_boxes); |
| 1748 |
|
| 1749 |
$ids = array(); |
| 1750 |
foreach ($meta_boxes as $meta_box) |
| 1751 |
{ |
| 1752 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 1753 |
$ids[] = $meta_box['id']; |
| 1754 |
} |
| 1755 |
|
| 1756 |
$tabs['tab_enquiry_details'] = array( |
| 1757 |
'name' => __( 'Details', 'propertyhive' ), |
| 1758 |
'metabox_ids' => $ids, |
| 1759 |
'post_type' => 'enquiry' |
| 1760 |
); |
| 1761 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'enquiry' ) |
| 1762 |
{ |
| 1763 |
$tabs['tab_enquiry_details']['ajax_actions'] = array( '^^ph_redraw_pinned_notes_grid(\'enquiry\')' ); |
| 1764 |
} |
| 1765 |
|
| 1766 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'enquiry' ) |
| 1767 |
{ |
| 1768 |
$meta_boxes = array(); |
| 1769 |
$meta_boxes[5] = array( |
| 1770 |
'id' => 'propertyhive-enquiry-history-notes', |
| 1771 |
'title' => __( 'Enquiry History & Notes', 'propertyhive' ), |
| 1772 |
'callback' => 'PH_Meta_Box_Enquiry_Notes::output', |
| 1773 |
'screen' => 'enquiry', |
| 1774 |
'context' => 'normal', |
| 1775 |
'priority' => 'high' |
| 1776 |
); |
| 1777 |
|
| 1778 |
$meta_boxes = apply_filters( 'propertyhive_enquiry_notes_meta_boxes', $meta_boxes ); |
| 1779 |
ksort($meta_boxes); |
| 1780 |
|
| 1781 |
$ids = array(); |
| 1782 |
foreach ($meta_boxes as $meta_box) |
| 1783 |
{ |
| 1784 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 1785 |
$ids[] = $meta_box['id']; |
| 1786 |
} |
| 1787 |
|
| 1788 |
$tabs['tab_enquiry_notes'] = array( |
| 1789 |
'name' => __( 'History & Notes', 'propertyhive' ), |
| 1790 |
'metabox_ids' => $ids, |
| 1791 |
'post_type' => 'enquiry', |
| 1792 |
'ajax_actions' => array( '^^ph_redraw_notes_grid(\'enquiry\')' ), |
| 1793 |
); |
| 1794 |
} |
| 1795 |
|
| 1796 |
// APPRAISAL |
| 1797 |
if (!isset($tabs)) $tabs = array(); |
| 1798 |
|
| 1799 |
/* APPRAISAL SUMMARY META BOXES */ |
| 1800 |
$meta_boxes = array(); |
| 1801 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'appraisal' ) |
| 1802 |
{ |
| 1803 |
if ( !empty($pinned_notes) ) |
| 1804 |
{ |
| 1805 |
$meta_boxes[1] = array( |
| 1806 |
'id' => 'propertyhive-appraisal-pinned-notes', |
| 1807 |
'title' => __( 'Pinned Notes', 'propertyhive' ), |
| 1808 |
'callback' => 'PH_Meta_Box_Appraisal_Pinned_Notes::output', |
| 1809 |
'screen' => 'appraisal', |
| 1810 |
'context' => 'normal', |
| 1811 |
'priority' => 'high', |
| 1812 |
); |
| 1813 |
} |
| 1814 |
} |
| 1815 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'appraisal' ) |
| 1816 |
{ |
| 1817 |
$meta_boxes[5] = array( |
| 1818 |
'id' => 'propertyhive-appraisal-details', |
| 1819 |
'title' => __( 'Appraisal Details', 'propertyhive' ), |
| 1820 |
'callback' => 'PH_Meta_Box_Appraisal_Details::output', |
| 1821 |
'screen' => 'appraisal', |
| 1822 |
'context' => 'normal', |
| 1823 |
'priority' => 'high' |
| 1824 |
); |
| 1825 |
} |
| 1826 |
$meta_boxes[10] = array( |
| 1827 |
'id' => 'propertyhive-appraisal-event', |
| 1828 |
'title' => __( 'Event Details', 'propertyhive' ), |
| 1829 |
'callback' => 'PH_Meta_Box_Appraisal_Event::output', |
| 1830 |
'screen' => 'appraisal', |
| 1831 |
'context' => 'normal', |
| 1832 |
'priority' => 'high' |
| 1833 |
); |
| 1834 |
$meta_boxes[15] = array( |
| 1835 |
'id' => 'propertyhive-appraisal-property-owner', |
| 1836 |
'title' => __( 'Property Owner Details', 'propertyhive' ), |
| 1837 |
'callback' => 'PH_Meta_Box_Appraisal_Property_Owner::output', |
| 1838 |
'screen' => 'appraisal', |
| 1839 |
'context' => 'normal', |
| 1840 |
'priority' => 'high' |
| 1841 |
); |
| 1842 |
$meta_boxes[20] = array( |
| 1843 |
'id' => 'propertyhive-appraisal-property', |
| 1844 |
'title' => __( 'Property Details', 'propertyhive' ), |
| 1845 |
'callback' => 'PH_Meta_Box_Appraisal_Property::output', |
| 1846 |
'screen' => 'appraisal', |
| 1847 |
'context' => 'normal', |
| 1848 |
'priority' => 'high' |
| 1849 |
); |
| 1850 |
|
| 1851 |
$meta_boxes = apply_filters( 'propertyhive_appraisal_summary_meta_boxes', $meta_boxes ); |
| 1852 |
ksort($meta_boxes); |
| 1853 |
|
| 1854 |
$ids = array(); |
| 1855 |
foreach ($meta_boxes as $meta_box) |
| 1856 |
{ |
| 1857 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 1858 |
$ids[] = $meta_box['id']; |
| 1859 |
} |
| 1860 |
|
| 1861 |
$tabs['tab_appraisal_summary'] = array( |
| 1862 |
'name' => __( 'Summary', 'propertyhive' ), |
| 1863 |
'metabox_ids' => $ids, |
| 1864 |
'post_type' => 'appraisal' |
| 1865 |
); |
| 1866 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'appraisal' ) |
| 1867 |
{ |
| 1868 |
$tabs['tab_appraisal_summary']['ajax_actions'] = array( '^^ph_redraw_pinned_notes_grid(\'appraisal\')' ); |
| 1869 |
} |
| 1870 |
|
| 1871 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'appraisal' ) |
| 1872 |
{ |
| 1873 |
$meta_boxes = array(); |
| 1874 |
$meta_boxes[5] = array( |
| 1875 |
'id' => 'propertyhive-appraisal-history-notes', |
| 1876 |
'title' => __( 'Appraisal History & Notes', 'propertyhive' ), |
| 1877 |
'callback' => 'PH_Meta_Box_Appraisal_Notes::output', |
| 1878 |
'screen' => 'appraisal', |
| 1879 |
'context' => 'normal', |
| 1880 |
'priority' => 'high' |
| 1881 |
); |
| 1882 |
|
| 1883 |
$meta_boxes = apply_filters( 'propertyhive_appraisal_notes_meta_boxes', $meta_boxes ); |
| 1884 |
ksort($meta_boxes); |
| 1885 |
|
| 1886 |
$ids = array(); |
| 1887 |
foreach ($meta_boxes as $meta_box) |
| 1888 |
{ |
| 1889 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 1890 |
$ids[] = $meta_box['id']; |
| 1891 |
} |
| 1892 |
|
| 1893 |
$tabs['tab_appraisal_notes'] = array( |
| 1894 |
'name' => __( 'History & Notes', 'propertyhive' ), |
| 1895 |
'metabox_ids' => $ids, |
| 1896 |
'post_type' => 'appraisal', |
| 1897 |
'ajax_actions' => array( '^^ph_redraw_notes_grid(\'appraisal\')' ), |
| 1898 |
); |
| 1899 |
|
| 1900 |
add_meta_box( 'propertyhive-appraisal-actions', __( 'Actions', 'propertyhive' ), 'PH_Meta_Box_Appraisal_Actions::output', 'appraisal', 'side' ); |
| 1901 |
} |
| 1902 |
|
| 1903 |
// VIEWING |
| 1904 |
if (!isset($tabs)) $tabs = array(); |
| 1905 |
|
| 1906 |
/* VIEWING SUMMARY META BOXES */ |
| 1907 |
$meta_boxes = array(); |
| 1908 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'viewing' ) |
| 1909 |
{ |
| 1910 |
if ( !empty($pinned_notes) ) |
| 1911 |
{ |
| 1912 |
$meta_boxes[1] = array( |
| 1913 |
'id' => 'propertyhive-viewing-pinned-notes', |
| 1914 |
'title' => __( 'Pinned Notes', 'propertyhive' ), |
| 1915 |
'callback' => 'PH_Meta_Box_Viewing_Pinned_Notes::output', |
| 1916 |
'screen' => 'viewing', |
| 1917 |
'context' => 'normal', |
| 1918 |
'priority' => 'high', |
| 1919 |
); |
| 1920 |
} |
| 1921 |
} |
| 1922 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'viewing' ) |
| 1923 |
{ |
| 1924 |
$meta_boxes[5] = array( |
| 1925 |
'id' => 'propertyhive-viewing-details', |
| 1926 |
'title' => __( 'Viewing Details', 'propertyhive' ), |
| 1927 |
'callback' => 'PH_Meta_Box_Viewing_Details::output', |
| 1928 |
'screen' => 'viewing', |
| 1929 |
'context' => 'normal', |
| 1930 |
'priority' => 'high' |
| 1931 |
); |
| 1932 |
} |
| 1933 |
$meta_boxes[10] = array( |
| 1934 |
'id' => 'propertyhive-viewing-event', |
| 1935 |
'title' => __( 'Event Details', 'propertyhive' ), |
| 1936 |
'callback' => 'PH_Meta_Box_Viewing_Event::output', |
| 1937 |
'screen' => 'viewing', |
| 1938 |
'context' => 'normal', |
| 1939 |
'priority' => 'high' |
| 1940 |
); |
| 1941 |
$meta_boxes[15] = array( |
| 1942 |
'id' => 'propertyhive-viewing-applicant', |
| 1943 |
'title' => __( 'Applicant Details', 'propertyhive' ), |
| 1944 |
'callback' => 'PH_Meta_Box_Viewing_Applicant::output', |
| 1945 |
'screen' => 'viewing', |
| 1946 |
'context' => 'normal', |
| 1947 |
'priority' => 'high' |
| 1948 |
); |
| 1949 |
$meta_boxes[20] = array( |
| 1950 |
'id' => 'propertyhive-viewing-property', |
| 1951 |
'title' => __( 'Property Details', 'propertyhive' ), |
| 1952 |
'callback' => 'PH_Meta_Box_Viewing_Property::output', |
| 1953 |
'screen' => 'viewing', |
| 1954 |
'context' => 'normal', |
| 1955 |
'priority' => 'high' |
| 1956 |
); |
| 1957 |
|
| 1958 |
$meta_boxes = apply_filters( 'propertyhive_viewing_summary_meta_boxes', $meta_boxes ); |
| 1959 |
ksort($meta_boxes); |
| 1960 |
|
| 1961 |
$ids = array(); |
| 1962 |
foreach ($meta_boxes as $meta_box) |
| 1963 |
{ |
| 1964 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 1965 |
$ids[] = $meta_box['id']; |
| 1966 |
} |
| 1967 |
|
| 1968 |
$tabs['tab_viewing_summary'] = array( |
| 1969 |
'name' => __( 'Summary', 'propertyhive' ), |
| 1970 |
'metabox_ids' => $ids, |
| 1971 |
'post_type' => 'viewing' |
| 1972 |
); |
| 1973 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'viewing' ) |
| 1974 |
{ |
| 1975 |
$tabs['tab_viewing_summary']['ajax_actions'] = array( '^^ph_redraw_pinned_notes_grid(\'viewing\')' ); |
| 1976 |
} |
| 1977 |
|
| 1978 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'viewing' ) |
| 1979 |
{ |
| 1980 |
$meta_boxes = array(); |
| 1981 |
$meta_boxes[5] = array( |
| 1982 |
'id' => 'propertyhive-viewing-history-notes', |
| 1983 |
'title' => __( 'Viewing History & Notes', 'propertyhive' ), |
| 1984 |
'callback' => 'PH_Meta_Box_Viewing_Notes::output', |
| 1985 |
'screen' => 'viewing', |
| 1986 |
'context' => 'normal', |
| 1987 |
'priority' => 'high' |
| 1988 |
); |
| 1989 |
|
| 1990 |
$meta_boxes = apply_filters( 'propertyhive_viewing_notes_meta_boxes', $meta_boxes ); |
| 1991 |
ksort($meta_boxes); |
| 1992 |
|
| 1993 |
$ids = array(); |
| 1994 |
foreach ($meta_boxes as $meta_box) |
| 1995 |
{ |
| 1996 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 1997 |
$ids[] = $meta_box['id']; |
| 1998 |
} |
| 1999 |
|
| 2000 |
$tabs['tab_viewing_notes'] = array( |
| 2001 |
'name' => __( 'History & Notes', 'propertyhive' ), |
| 2002 |
'metabox_ids' => $ids, |
| 2003 |
'post_type' => 'viewing', |
| 2004 |
'ajax_actions' => array( '^^ph_redraw_notes_grid(\'viewing\')' ), |
| 2005 |
); |
| 2006 |
|
| 2007 |
add_meta_box( 'propertyhive-viewing-actions', __( 'Actions', 'propertyhive' ), 'PH_Meta_Box_Viewing_Actions::output', 'viewing', 'side' ); |
| 2008 |
} |
| 2009 |
|
| 2010 |
// OFFER |
| 2011 |
if (!isset($tabs)) $tabs = array(); |
| 2012 |
|
| 2013 |
/* OFFER SUMMARY META BOXES */ |
| 2014 |
$meta_boxes = array(); |
| 2015 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'offer' ) |
| 2016 |
{ |
| 2017 |
if ( !empty($pinned_notes) ) |
| 2018 |
{ |
| 2019 |
$meta_boxes[1] = array( |
| 2020 |
'id' => 'propertyhive-offer-pinned-notes', |
| 2021 |
'title' => __( 'Pinned Notes', 'propertyhive' ), |
| 2022 |
'callback' => 'PH_Meta_Box_Offer_Pinned_Notes::output', |
| 2023 |
'screen' => 'offer', |
| 2024 |
'context' => 'normal', |
| 2025 |
'priority' => 'high', |
| 2026 |
); |
| 2027 |
} |
| 2028 |
} |
| 2029 |
$meta_boxes[5] = array( |
| 2030 |
'id' => 'propertyhive-offer-details', |
| 2031 |
'title' => __( 'Offer Details', 'propertyhive' ), |
| 2032 |
'callback' => 'PH_Meta_Box_Offer_Details::output', |
| 2033 |
'screen' => 'offer', |
| 2034 |
'context' => 'normal', |
| 2035 |
'priority' => 'high' |
| 2036 |
); |
| 2037 |
$meta_boxes[10] = array( |
| 2038 |
'id' => 'propertyhive-offer-property', |
| 2039 |
'title' => __( 'Property Details', 'propertyhive' ), |
| 2040 |
'callback' => 'PH_Meta_Box_Offer_Property::output', |
| 2041 |
'screen' => 'offer', |
| 2042 |
'context' => 'normal', |
| 2043 |
'priority' => 'high' |
| 2044 |
); |
| 2045 |
$meta_boxes[15] = array( |
| 2046 |
'id' => 'propertyhive-offer-property-owner-solicitor', |
| 2047 |
'title' => __( 'Property Owner Solicitor Details', 'propertyhive' ), |
| 2048 |
'callback' => 'PH_Meta_Box_Offer_Property_Owner_Solicitor::output', |
| 2049 |
'screen' => 'offer', |
| 2050 |
'context' => 'normal', |
| 2051 |
'priority' => 'high' |
| 2052 |
); |
| 2053 |
$meta_boxes[20] = array( |
| 2054 |
'id' => 'propertyhive-offer-applicant', |
| 2055 |
'title' => __( 'Applicant Details', 'propertyhive' ), |
| 2056 |
'callback' => 'PH_Meta_Box_Offer_Applicant::output', |
| 2057 |
'screen' => 'offer', |
| 2058 |
'context' => 'normal', |
| 2059 |
'priority' => 'high' |
| 2060 |
); |
| 2061 |
$meta_boxes[25] = array( |
| 2062 |
'id' => 'propertyhive-offer-applicant-solicitor', |
| 2063 |
'title' => __( 'Applicant Solicitor Details', 'propertyhive' ), |
| 2064 |
'callback' => 'PH_Meta_Box_Offer_Applicant_Solicitor::output', |
| 2065 |
'screen' => 'offer', |
| 2066 |
'context' => 'normal', |
| 2067 |
'priority' => 'high' |
| 2068 |
); |
| 2069 |
|
| 2070 |
|
| 2071 |
$meta_boxes = apply_filters( 'propertyhive_offer_summary_meta_boxes', $meta_boxes ); |
| 2072 |
ksort($meta_boxes); |
| 2073 |
|
| 2074 |
$ids = array(); |
| 2075 |
foreach ($meta_boxes as $meta_box) |
| 2076 |
{ |
| 2077 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 2078 |
$ids[] = $meta_box['id']; |
| 2079 |
} |
| 2080 |
|
| 2081 |
$tabs['tab_offer_summary'] = array( |
| 2082 |
'name' => __( 'Summary', 'propertyhive' ), |
| 2083 |
'metabox_ids' => $ids, |
| 2084 |
'post_type' => 'offer' |
| 2085 |
); |
| 2086 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'offer' ) |
| 2087 |
{ |
| 2088 |
$tabs['tab_offer_summary']['ajax_actions'] = array( '^^ph_redraw_pinned_notes_grid(\'offer\')' ); |
| 2089 |
} |
| 2090 |
|
| 2091 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'offer' ) |
| 2092 |
{ |
| 2093 |
$meta_boxes = array(); |
| 2094 |
$meta_boxes[5] = array( |
| 2095 |
'id' => 'propertyhive-offer-history-notes', |
| 2096 |
'title' => __( 'Offer History & Notes', 'propertyhive' ), |
| 2097 |
'callback' => 'PH_Meta_Box_Offer_Notes::output', |
| 2098 |
'screen' => 'offer', |
| 2099 |
'context' => 'normal', |
| 2100 |
'priority' => 'high' |
| 2101 |
); |
| 2102 |
|
| 2103 |
$meta_boxes = apply_filters( 'propertyhive_offer_notes_meta_boxes', $meta_boxes ); |
| 2104 |
ksort($meta_boxes); |
| 2105 |
|
| 2106 |
$ids = array(); |
| 2107 |
foreach ($meta_boxes as $meta_box) |
| 2108 |
{ |
| 2109 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 2110 |
$ids[] = $meta_box['id']; |
| 2111 |
} |
| 2112 |
|
| 2113 |
$tabs['tab_offer_notes'] = array( |
| 2114 |
'name' => __( 'History & Notes', 'propertyhive' ), |
| 2115 |
'metabox_ids' => $ids, |
| 2116 |
'post_type' => 'offer', |
| 2117 |
'ajax_actions' => array( '^^ph_redraw_notes_grid(\'offer\')' ), |
| 2118 |
); |
| 2119 |
|
| 2120 |
add_meta_box( 'propertyhive-offer-actions', __( 'Actions', 'propertyhive' ), 'PH_Meta_Box_Offer_Actions::output', 'offer', 'side' ); |
| 2121 |
} |
| 2122 |
|
| 2123 |
// SALE |
| 2124 |
if (!isset($tabs)) $tabs = array(); |
| 2125 |
|
| 2126 |
/* SALE SUMMARY META BOXES */ |
| 2127 |
$meta_boxes = array(); |
| 2128 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'sale' ) |
| 2129 |
{ |
| 2130 |
if ( !empty($pinned_notes) ) |
| 2131 |
{ |
| 2132 |
$meta_boxes[1] = array( |
| 2133 |
'id' => 'propertyhive-sale-pinned-notes', |
| 2134 |
'title' => __( 'Pinned Notes', 'propertyhive' ), |
| 2135 |
'callback' => 'PH_Meta_Box_Sale_Pinned_Notes::output', |
| 2136 |
'screen' => 'sale', |
| 2137 |
'context' => 'normal', |
| 2138 |
'priority' => 'high', |
| 2139 |
); |
| 2140 |
} |
| 2141 |
} |
| 2142 |
$meta_boxes[5] = array( |
| 2143 |
'id' => 'propertyhive-sale-details', |
| 2144 |
'title' => __( 'Sale Details', 'propertyhive' ), |
| 2145 |
'callback' => 'PH_Meta_Box_Sale_Details::output', |
| 2146 |
'screen' => 'sale', |
| 2147 |
'context' => 'normal', |
| 2148 |
'priority' => 'high' |
| 2149 |
); |
| 2150 |
$meta_boxes[10] = array( |
| 2151 |
'id' => 'propertyhive-sale-property', |
| 2152 |
'title' => __( 'Property Details', 'propertyhive' ), |
| 2153 |
'callback' => 'PH_Meta_Box_Sale_Property::output', |
| 2154 |
'screen' => 'sale', |
| 2155 |
'context' => 'normal', |
| 2156 |
'priority' => 'high' |
| 2157 |
); |
| 2158 |
$meta_boxes[15] = array( |
| 2159 |
'id' => 'propertyhive-sale-property-owner-solicitor', |
| 2160 |
'title' => __( 'Property Owner Solicitor Details', 'propertyhive' ), |
| 2161 |
'callback' => 'PH_Meta_Box_Sale_Property_Owner_Solicitor::output', |
| 2162 |
'screen' => 'sale', |
| 2163 |
'context' => 'normal', |
| 2164 |
'priority' => 'high' |
| 2165 |
); |
| 2166 |
$meta_boxes[20] = array( |
| 2167 |
'id' => 'propertyhive-sale-applicant', |
| 2168 |
'title' => __( 'Applicant Details', 'propertyhive' ), |
| 2169 |
'callback' => 'PH_Meta_Box_Sale_Applicant::output', |
| 2170 |
'screen' => 'sale', |
| 2171 |
'context' => 'normal', |
| 2172 |
'priority' => 'high' |
| 2173 |
); |
| 2174 |
$meta_boxes[25] = array( |
| 2175 |
'id' => 'propertyhive-sale-applicant-solicitor', |
| 2176 |
'title' => __( 'Applicant Solicitor Details', 'propertyhive' ), |
| 2177 |
'callback' => 'PH_Meta_Box_Sale_Applicant_Solicitor::output', |
| 2178 |
'screen' => 'sale', |
| 2179 |
'context' => 'normal', |
| 2180 |
'priority' => 'high' |
| 2181 |
); |
| 2182 |
|
| 2183 |
$meta_boxes = apply_filters( 'propertyhive_sale_summary_meta_boxes', $meta_boxes ); |
| 2184 |
ksort($meta_boxes); |
| 2185 |
|
| 2186 |
$ids = array(); |
| 2187 |
foreach ($meta_boxes as $meta_box) |
| 2188 |
{ |
| 2189 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 2190 |
$ids[] = $meta_box['id']; |
| 2191 |
} |
| 2192 |
|
| 2193 |
$tabs['tab_sale_summary'] = array( |
| 2194 |
'name' => __( 'Summary', 'propertyhive' ), |
| 2195 |
'metabox_ids' => $ids, |
| 2196 |
'post_type' => 'sale' |
| 2197 |
); |
| 2198 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'sale' ) |
| 2199 |
{ |
| 2200 |
$tabs['tab_sale_summary']['ajax_actions'] = array( '^^ph_redraw_pinned_notes_grid(\'sale\')' ); |
| 2201 |
} |
| 2202 |
|
| 2203 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'sale' ) |
| 2204 |
{ |
| 2205 |
$meta_boxes = array(); |
| 2206 |
$meta_boxes[5] = array( |
| 2207 |
'id' => 'propertyhive-sale-history-notes', |
| 2208 |
'title' => __( 'Sale History & Notes', 'propertyhive' ), |
| 2209 |
'callback' => 'PH_Meta_Box_Sale_Notes::output', |
| 2210 |
'screen' => 'sale', |
| 2211 |
'context' => 'normal', |
| 2212 |
'priority' => 'high' |
| 2213 |
); |
| 2214 |
|
| 2215 |
$meta_boxes = apply_filters( 'propertyhive_sale_notes_meta_boxes', $meta_boxes ); |
| 2216 |
ksort($meta_boxes); |
| 2217 |
|
| 2218 |
$ids = array(); |
| 2219 |
foreach ($meta_boxes as $meta_box) |
| 2220 |
{ |
| 2221 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 2222 |
$ids[] = $meta_box['id']; |
| 2223 |
} |
| 2224 |
|
| 2225 |
$tabs['tab_sale_notes'] = array( |
| 2226 |
'name' => __( 'History & Notes', 'propertyhive' ), |
| 2227 |
'metabox_ids' => $ids, |
| 2228 |
'post_type' => 'sale', |
| 2229 |
'ajax_actions' => array( '^^ph_redraw_notes_grid(\'sale\')' ), |
| 2230 |
); |
| 2231 |
|
| 2232 |
add_meta_box( 'propertyhive-sale-actions', __( 'Actions', 'propertyhive' ), 'PH_Meta_Box_Sale_Actions::output', 'sale', 'side' ); |
| 2233 |
} |
| 2234 |
|
| 2235 |
// TENANCY |
| 2236 |
if (!isset($tabs)) $tabs = array(); |
| 2237 |
|
| 2238 |
/* TENANCY SUMMARY META BOXES */ |
| 2239 |
$meta_boxes = array(); |
| 2240 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'tenancy' ) |
| 2241 |
{ |
| 2242 |
if ( !empty($pinned_notes) ) |
| 2243 |
{ |
| 2244 |
$meta_boxes[1] = array( |
| 2245 |
'id' => 'propertyhive-tenancy-pinned-notes', |
| 2246 |
'title' => __( 'Pinned Notes', 'propertyhive' ), |
| 2247 |
'callback' => 'PH_Meta_Box_Tenancy_Pinned_Notes::output', |
| 2248 |
'screen' => 'tenancy', |
| 2249 |
'context' => 'normal', |
| 2250 |
'priority' => 'high', |
| 2251 |
); |
| 2252 |
} |
| 2253 |
} |
| 2254 |
$meta_boxes[5] = array( |
| 2255 |
'id' => 'propertyhive-tenancy-details', |
| 2256 |
'title' => __( 'Tenancy Details', 'propertyhive' ), |
| 2257 |
'callback' => 'PH_Meta_Box_Tenancy_Details::output', |
| 2258 |
'screen' => 'tenancy', |
| 2259 |
'context' => 'normal', |
| 2260 |
'priority' => 'high' |
| 2261 |
); |
| 2262 |
$meta_boxes[10] = array( |
| 2263 |
'id' => 'propertyhive-tenancy-property', |
| 2264 |
'title' => __( 'Property', 'propertyhive' ), |
| 2265 |
'callback' => 'PH_Meta_Box_Tenancy_Property::output', |
| 2266 |
'screen' => 'tenancy', |
| 2267 |
'context' => 'normal', |
| 2268 |
'priority' => 'high' |
| 2269 |
); |
| 2270 |
$meta_boxes[15] = array( |
| 2271 |
'id' => 'propertyhive-tenancy-applicant', |
| 2272 |
'title' => __( 'Tenants', 'propertyhive' ), |
| 2273 |
'callback' => 'PH_Meta_Box_Tenancy_Applicant::output', |
| 2274 |
'screen' => 'tenancy', |
| 2275 |
'context' => 'normal', |
| 2276 |
'priority' => 'high' |
| 2277 |
); |
| 2278 |
|
| 2279 |
$meta_boxes = apply_filters( 'propertyhive_tenancy_summary_meta_boxes', $meta_boxes ); |
| 2280 |
ksort($meta_boxes); |
| 2281 |
|
| 2282 |
$ids = array(); |
| 2283 |
foreach ($meta_boxes as $meta_box) |
| 2284 |
{ |
| 2285 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 2286 |
$ids[] = $meta_box['id']; |
| 2287 |
} |
| 2288 |
|
| 2289 |
$tabs['tab_tenancy_summary'] = array( |
| 2290 |
'name' => __( 'Summary', 'propertyhive' ), |
| 2291 |
'metabox_ids' => $ids, |
| 2292 |
'post_type' => 'tenancy' |
| 2293 |
); |
| 2294 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'tenancy' ) |
| 2295 |
{ |
| 2296 |
$tabs['tab_tenancy_summary']['ajax_actions'] = array( '^^ph_redraw_pinned_notes_grid(\'tenancy\')' ); |
| 2297 |
} |
| 2298 |
|
| 2299 |
/* TENANCY DEPOSIT SCHEME META BOXES */ |
| 2300 |
$meta_boxes = array(); |
| 2301 |
$meta_boxes[5] = array( |
| 2302 |
'id' => 'propertyhive-tenancy-deposit-scheme', |
| 2303 |
'title' => __( 'Deposit Scheme Details', 'propertyhive' ), |
| 2304 |
'callback' => 'PH_Meta_Box_Tenancy_Deposit_Scheme::output', |
| 2305 |
'screen' => 'tenancy', |
| 2306 |
'context' => 'normal', |
| 2307 |
'priority' => 'high' |
| 2308 |
); |
| 2309 |
|
| 2310 |
$meta_boxes = apply_filters( 'propertyhive_tenancy_deposit_meta_boxes', $meta_boxes ); |
| 2311 |
ksort($meta_boxes); |
| 2312 |
|
| 2313 |
$ids = array(); |
| 2314 |
foreach ($meta_boxes as $meta_box) |
| 2315 |
{ |
| 2316 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 2317 |
$ids[] = $meta_box['id']; |
| 2318 |
} |
| 2319 |
|
| 2320 |
$tabs['tab_tenancy_deposit_scheme'] = array( |
| 2321 |
'name' => __( 'Deposit Scheme', 'propertyhive' ), |
| 2322 |
'metabox_ids' => $ids, |
| 2323 |
'post_type' => 'tenancy' |
| 2324 |
); |
| 2325 |
|
| 2326 |
/* MANAGEMENT META BOXES */ |
| 2327 |
$meta_boxes = array(); |
| 2328 |
$meta_boxes[5] = array( |
| 2329 |
'id' => 'propertyhive-tenancy-management', |
| 2330 |
'title' => __( 'Management Details', 'propertyhive' ), |
| 2331 |
'callback' => 'PH_Meta_Box_Tenancy_Management::output', |
| 2332 |
'screen' => 'tenancy', |
| 2333 |
'context' => 'normal', |
| 2334 |
'priority' => 'high' |
| 2335 |
); |
| 2336 |
|
| 2337 |
$meta_boxes[10] = array( |
| 2338 |
'id' => 'propertyhive-management-dates', |
| 2339 |
'title' => __( 'Management Dates', 'propertyhive' ), |
| 2340 |
'callback' => 'PH_Meta_Box_Management_Dates::output', |
| 2341 |
'screen' => 'tenancy', |
| 2342 |
'context' => 'normal', |
| 2343 |
'priority' => 'high' |
| 2344 |
); |
| 2345 |
|
| 2346 |
$meta_boxes = apply_filters( 'propertyhive_tenancy_management_meta_boxes', $meta_boxes ); |
| 2347 |
ksort($meta_boxes); |
| 2348 |
|
| 2349 |
$ids = array(); |
| 2350 |
foreach ($meta_boxes as $meta_box) |
| 2351 |
{ |
| 2352 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 2353 |
$ids[] = $meta_box['id']; |
| 2354 |
} |
| 2355 |
|
| 2356 |
$tabs['tab_tenancy_management'] = array( |
| 2357 |
'name' => __( 'Management', 'propertyhive' ), |
| 2358 |
'metabox_ids' => $ids, |
| 2359 |
'post_type' => 'tenancy' |
| 2360 |
); |
| 2361 |
|
| 2362 |
/* TENANCY METER READINGS META BOXES */ |
| 2363 |
$meta_boxes = array(); |
| 2364 |
$meta_boxes[5] = array( |
| 2365 |
'id' => 'propertyhive-tenancy-meter-readings', |
| 2366 |
'title' => __( 'Meter Readings', 'propertyhive' ), |
| 2367 |
'callback' => 'PH_Meta_Box_Tenancy_Meter_Readings::output', |
| 2368 |
'screen' => 'tenancy', |
| 2369 |
'context' => 'normal', |
| 2370 |
'priority' => 'high' |
| 2371 |
); |
| 2372 |
|
| 2373 |
$meta_boxes = apply_filters( 'propertyhive_tenancy_meter_readings_meta_boxes', $meta_boxes ); |
| 2374 |
ksort($meta_boxes); |
| 2375 |
|
| 2376 |
$ids = array(); |
| 2377 |
foreach ($meta_boxes as $meta_box) |
| 2378 |
{ |
| 2379 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 2380 |
$ids[] = $meta_box['id']; |
| 2381 |
} |
| 2382 |
|
| 2383 |
$tabs['tab_tenancy_meter_readings'] = array( |
| 2384 |
'name' => __( 'Meter Readings', 'propertyhive' ), |
| 2385 |
'metabox_ids' => $ids, |
| 2386 |
'post_type' => 'tenancy' |
| 2387 |
); |
| 2388 |
|
| 2389 |
if ( $pagenow != 'post-new.php' && get_post_type($post->ID) == 'tenancy' ) |
| 2390 |
{ |
| 2391 |
/* HISTORY & NOTES META BOXES */ |
| 2392 |
$meta_boxes = array(); |
| 2393 |
$meta_boxes[5] = array( |
| 2394 |
'id' => 'propertyhive-tenancy-history-notes', |
| 2395 |
'title' => __( 'Tenancy History & Notes', 'propertyhive' ), |
| 2396 |
'callback' => 'PH_Meta_Box_Tenancy_Notes::output', |
| 2397 |
'screen' => 'tenancy', |
| 2398 |
'context' => 'normal', |
| 2399 |
'priority' => 'high' |
| 2400 |
); |
| 2401 |
|
| 2402 |
$meta_boxes = apply_filters( 'propertyhive_tenancy_notes_meta_boxes', $meta_boxes ); |
| 2403 |
ksort($meta_boxes); |
| 2404 |
|
| 2405 |
$ids = array(); |
| 2406 |
foreach ($meta_boxes as $meta_box) |
| 2407 |
{ |
| 2408 |
add_meta_box( $meta_box['id'], $meta_box['title'], $meta_box['callback'], $meta_box['screen'], $meta_box['context'], $meta_box['priority'] ); |
| 2409 |
$ids[] = $meta_box['id']; |
| 2410 |
} |
| 2411 |
|
| 2412 |
$tabs['tab_tenancy_notes'] = array( |
| 2413 |
'name' => __( 'History & Notes', 'propertyhive' ), |
| 2414 |
'metabox_ids' => $ids, |
| 2415 |
'post_type' => 'tenancy', |
| 2416 |
'ajax_actions' => array( '^^ph_redraw_notes_grid(\'tenancy\')' ), |
| 2417 |
); |
| 2418 |
} |
| 2419 |
|
| 2420 |
$tabs = apply_filters( 'propertyhive_tabs', $tabs ); |
| 2421 |
|
| 2422 |
// Force order of meta boxes |
| 2423 |
$meta_box_ids = array(); |
| 2424 |
if ( |
| 2425 |
in_array( |
| 2426 |
get_post_type($post->ID), |
| 2427 |
apply_filters( 'propertyhive_post_types_with_tabs', array('property', 'contact', 'enquiry', 'appraisal', 'viewing', 'offer', 'sale', 'tenancy') ) |
| 2428 |
) |
| 2429 |
) |
| 2430 |
{ |
| 2431 |
foreach ( $tabs as $tab_id => $tab_options) |
| 2432 |
{ |
| 2433 |
if ( isset($tab_options['post_type']) && $tab_options['post_type'] == get_post_type($post->ID) ) |
| 2434 |
{ |
| 2435 |
$meta_box_ids = array_merge( $meta_box_ids, $tab_options['metabox_ids'] ); |
| 2436 |
} |
| 2437 |
} |
| 2438 |
} |
| 2439 |
|
| 2440 |
if (!empty($meta_box_ids) ) |
| 2441 |
{ |
| 2442 |
$existing_meta_box_order = get_user_meta( get_current_user_id(), 'meta-box-order_' . get_post_type($post->ID), TRUE ); |
| 2443 |
if ( $existing_meta_box_order == '' ) |
| 2444 |
{ |
| 2445 |
$existing_meta_box_order = array(); |
| 2446 |
$existing_meta_box_order['side'] = ''; |
| 2447 |
$existing_meta_box_order['advanced'] = ''; |
| 2448 |
} |
| 2449 |
$existing_meta_box_order['normal'] = implode(",", $meta_box_ids); |
| 2450 |
|
| 2451 |
update_user_meta( get_current_user_id(), 'meta-box-order_' . get_post_type($post->ID), $existing_meta_box_order ); |
| 2452 |
} |
| 2453 |
|
| 2454 |
// TO DO: move this so it works when in one column |
| 2455 |
add_action( 'edit_form_after_title', array( $this, 'draw_meta_box_tabs' ), 31, 1); |
| 2456 |
} |
| 2457 |
|
| 2458 |
/** |
| 2459 |
* Draw meta box tabs |
| 2460 |
*/ |
| 2461 |
public function draw_meta_box_tabs() { |
| 2462 |
|
| 2463 |
global $post, $tabs; |
| 2464 |
|
| 2465 |
if ( |
| 2466 |
!empty($tabs) && |
| 2467 |
in_array( |
| 2468 |
$post->post_type, |
| 2469 |
apply_filters( 'propertyhive_post_types_with_tabs', array('property', 'contact', 'enquiry', 'appraisal', 'viewing', 'offer', 'sale', 'tenancy') ) |
| 2470 |
) |
| 2471 |
) |
| 2472 |
{ |
| 2473 |
$meta_boxes_under_tabs = array(); |
| 2474 |
|
| 2475 |
$i = 0; |
| 2476 |
echo '<div id="propertyhive_metabox_tabs" style="margin-top:15px">'; |
| 2477 |
foreach ($tabs as $tab_id => $tab) |
| 2478 |
{ |
| 2479 |
if (isset($tab['post_type']) && $post->post_type == $tab['post_type']) |
| 2480 |
{ |
| 2481 |
echo '<a href="#' . implode("|#", $tab['metabox_ids']) . '" id="' . esc_attr($tab_id) . '" class="button' . ( ($i == 0) ? ' button-primary' : '') . '"'; |
| 2482 |
if ( isset($tab['ajax_actions']) ) |
| 2483 |
{ |
| 2484 |
echo ' data-ajax-actions="' . esc_attr(implode("|", $tab['ajax_actions'])) . '"'; |
| 2485 |
} |
| 2486 |
echo '>' . esc_html($tab['name']) . '</a> '; |
| 2487 |
|
| 2488 |
$meta_boxes_under_tabs[] = $tab['metabox_ids']; |
| 2489 |
|
| 2490 |
++$i; |
| 2491 |
} |
| 2492 |
} |
| 2493 |
echo '</div><br>'; |
| 2494 |
|
| 2495 |
// hidden field to keep track of selected hash |
| 2496 |
echo '<input type="hidden" name="propertyhive_selected_metabox_tab" id="propertyhive_selected_metabox_tab" value="">'; |
| 2497 |
|
| 2498 |
if (!empty($meta_boxes_under_tabs)) |
| 2499 |
{ |
| 2500 |
echo ' |
| 2501 |
<script> |
| 2502 |
var meta_boxes_under_tabs = ' . json_encode($meta_boxes_under_tabs) . '; |
| 2503 |
|
| 2504 |
var ajax_actions_executed = new Array(); |
| 2505 |
|
| 2506 |
jQuery(document).ready(function() |
| 2507 |
{ |
| 2508 |
// Hide all on page load |
| 2509 |
hide_meta_box_tabs(); |
| 2510 |
|
| 2511 |
// Show first meta box |
| 2512 |
//jQuery(\'#\' + meta_boxes_under_tabs[0][0] + \'\').show(); |
| 2513 |
for (var i in meta_boxes_under_tabs[0]) |
| 2514 |
{ |
| 2515 |
jQuery(\'#\' + meta_boxes_under_tabs[0][i] + \'\').show(); |
| 2516 |
} |
| 2517 |
//jQuery(\'#propertyhive_metabox_tabs a:first-child\').trigger(\'click\'); |
| 2518 |
|
| 2519 |
// Set first button as primary |
| 2520 |
jQuery(\'#propertyhive_metabox_tabs a:first-child\').addClass(\'button-primary\'); |
| 2521 |
|
| 2522 |
// Hide meta boxes and show correct one when tab clicked |
| 2523 |
jQuery(\'#propertyhive_metabox_tabs a\').click(function(e) |
| 2524 |
{ |
| 2525 |
e.preventDefault(); |
| 2526 |
|
| 2527 |
hide_meta_box_tabs(); |
| 2528 |
|
| 2529 |
var this_href = jQuery(this).attr(\'href\').split(\'|\'); |
| 2530 |
|
| 2531 |
for (var i in this_href) |
| 2532 |
{ |
| 2533 |
jQuery(this_href[i]).show(); |
| 2534 |
} |
| 2535 |
|
| 2536 |
jQuery(this).addClass(\'button-primary\'); |
| 2537 |
|
| 2538 |
' . ( ( $post->post_type == 'property' ) ? 'if (jQuery(this).attr(\'id\') == \'tab_details\') { showHideDepartmentMetaBox(); }' : '' ) . ' |
| 2539 |
' . ( ( $post->post_type == 'property' ) ? 'if (jQuery(this).attr(\'id\') == \'tab_descriptions\') { showHideRoomsMetaBox(); }' : '' ) . ' |
| 2540 |
' . ( ( $post->post_type == 'property' ) ? 'if (jQuery(this).attr(\'id\') == \'tab_descriptions\') { showHideDescriptionsMetaBox(); }' : '' ) . ' |
| 2541 |
|
| 2542 |
if ( jQuery(this).attr(\'data-ajax-actions\') && jQuery(this).attr(\'data-ajax-actions\') != \'\' ) |
| 2543 |
{ |
| 2544 |
var ajax_actions = jQuery(this).attr(\'data-ajax-actions\').split(\'|\'); |
| 2545 |
|
| 2546 |
for ( var i in ajax_actions ) |
| 2547 |
{ |
| 2548 |
var ajax_action = ajax_actions[i].split(\'^\'); |
| 2549 |
|
| 2550 |
jQuery(\'#\' + ajax_action[0].replace(\'get_\', \'propertyhive_\')).html(\'Loading...\'); |
| 2551 |
|
| 2552 |
if ( ajax_action[2] ) // callback |
| 2553 |
{ |
| 2554 |
eval(ajax_action[2]); |
| 2555 |
} |
| 2556 |
else |
| 2557 |
{ |
| 2558 |
var data = { |
| 2559 |
action: \'propertyhive_\' + ajax_action[0], |
| 2560 |
post_id: ' . (int)$post->ID . ', |
| 2561 |
security: ajax_action[1] |
| 2562 |
} |
| 2563 |
|
| 2564 |
jQuery.post( \'' . esc_url(admin_url('admin-ajax.php')) . '\', data, function(response) |
| 2565 |
{ |
| 2566 |
jQuery(\'#\' + ajax_action[0].replace(\'get_\', \'propertyhive_\')).html(response); |
| 2567 |
activateTipTip(); |
| 2568 |
}, \'html\'); |
| 2569 |
} |
| 2570 |
} |
| 2571 |
} |
| 2572 |
|
| 2573 |
//window.location.hash = jQuery(this).attr(\'href\'); |
| 2574 |
history.pushState({}, \'\', \'#\' + jQuery(this).attr(\'href\').replace(/#/g, \'\').replace(/\|/g, \'%7C\')); |
| 2575 |
|
| 2576 |
jQuery(\'#propertyhive_selected_metabox_tab\').val(jQuery(this).attr(\'href\').replace(/#/g, \'\').replace(/\|/g, \'%7C\')); |
| 2577 |
|
| 2578 |
return false; |
| 2579 |
}); |
| 2580 |
|
| 2581 |
// Set default tab if hash set |
| 2582 |
if (window.location.hash != \'\') |
| 2583 |
{ |
| 2584 |
var hash = window.location.hash; |
| 2585 |
if ( window.location.hash.indexOf(\'%7C\') ) |
| 2586 |
{ |
| 2587 |
hash = window.location.hash.replace(/%7C/g, \'|#\'); |
| 2588 |
} |
| 2589 |
jQuery("#propertyhive_metabox_tabs a[href*=\'" + hash + "\']").trigger(\'click\'); |
| 2590 |
} |
| 2591 |
}); |
| 2592 |
|
| 2593 |
jQuery(window).on(\'load\', function() |
| 2594 |
{ |
| 2595 |
if (window.location.hash == \'\') |
| 2596 |
{ |
| 2597 |
if ( jQuery(\'#propertyhive_metabox_tabs a\').eq(0).attr(\'data-ajax-actions\') && jQuery(\'#propertyhive_metabox_tabs a\').eq(0).attr(\'data-ajax-actions\') != \'\' ) |
| 2598 |
{ |
| 2599 |
var ajax_actions = jQuery(\'#propertyhive_metabox_tabs a\').eq(0).attr(\'data-ajax-actions\').split(\'|\'); |
| 2600 |
|
| 2601 |
for ( var i in ajax_actions ) |
| 2602 |
{ |
| 2603 |
var ajax_action = ajax_actions[i].split(\'^\'); |
| 2604 |
|
| 2605 |
jQuery(\'#\' + ajax_action[0].replace(\'get_\', \'propertyhive_\')).html(\'Loading...\'); |
| 2606 |
|
| 2607 |
if ( ajax_action[2] ) // callback |
| 2608 |
{ |
| 2609 |
eval(ajax_action[2]); |
| 2610 |
} |
| 2611 |
else |
| 2612 |
{ |
| 2613 |
var data = { |
| 2614 |
action: \'propertyhive_\' + ajax_action[0], |
| 2615 |
post_id: ' . (int)$post->ID . ', |
| 2616 |
security: ajax_action[1] |
| 2617 |
} |
| 2618 |
|
| 2619 |
jQuery.post( \'' . esc_url(admin_url('admin-ajax.php')) . '\', data, function(response) |
| 2620 |
{ |
| 2621 |
jQuery(\'#\' + ajax_action[0].replace(\'get_\', \'propertyhive_\')).html(response); |
| 2622 |
activateTipTip(); |
| 2623 |
}, \'html\'); |
| 2624 |
} |
| 2625 |
} |
| 2626 |
} |
| 2627 |
} |
| 2628 |
}); |
| 2629 |
|
| 2630 |
function hide_meta_box_tabs() |
| 2631 |
{ |
| 2632 |
for (var i in meta_boxes_under_tabs) |
| 2633 |
{ |
| 2634 |
for (var j in meta_boxes_under_tabs[i]) |
| 2635 |
{ |
| 2636 |
jQuery(\'#\' + meta_boxes_under_tabs[i][j] + \'\').hide(); |
| 2637 |
} |
| 2638 |
} |
| 2639 |
|
| 2640 |
jQuery(\'#propertyhive_metabox_tabs a\').removeClass(\'button-primary\'); |
| 2641 |
} |
| 2642 |
</script> |
| 2643 |
'; |
| 2644 |
} |
| 2645 |
} |
| 2646 |
|
| 2647 |
} |
| 2648 |
|
| 2649 |
/** |
| 2650 |
* Remove bloat |
| 2651 |
*/ |
| 2652 |
public function remove_meta_boxes() { |
| 2653 |
//remove_meta_box( 'submitdiv', 'property', 'side' ); |
| 2654 |
remove_meta_box( 'postexcerpt', 'property', 'normal' ); |
| 2655 |
remove_meta_box( 'pageparentdiv', 'property', 'side' ); |
| 2656 |
remove_meta_box( 'commentstatusdiv', 'property', 'normal' ); |
| 2657 |
remove_meta_box( 'commentstatusdiv', 'property', 'side' ); |
| 2658 |
remove_meta_box( 'commentsdiv', 'product', 'normal' ); |
| 2659 |
} |
| 2660 |
|
| 2661 |
/** |
| 2662 |
* Rename core meta boxes |
| 2663 |
*/ |
| 2664 |
public function rename_meta_boxes() { |
| 2665 |
global $post; |
| 2666 |
|
| 2667 |
// Comments/Reviews |
| 2668 |
if ( isset( $post ) && ( 'publish' == $post->post_status || 'private' == $post->post_status ) ) { |
| 2669 |
//remove_meta_box( 'commentsdiv', 'product', 'normal' ); |
| 2670 |
|
| 2671 |
//add_meta_box( 'commentsdiv', __( 'Reviews', 'propertyhive' ), 'post_comment_meta_box', 'product', 'normal' ); |
| 2672 |
} |
| 2673 |
} |
| 2674 |
|
| 2675 |
/** |
| 2676 |
* Check if we're saving, then trigger an action based on the post type |
| 2677 |
* |
| 2678 |
* @param int $post_id |
| 2679 |
* @param object $post |
| 2680 |
*/ |
| 2681 |
public function save_meta_boxes( $post_id, $post ) { |
| 2682 |
|
| 2683 |
// $post_id and $post are required |
| 2684 |
if ( empty( $post_id ) || empty( $post ) ) { |
| 2685 |
return; |
| 2686 |
} |
| 2687 |
|
| 2688 |
// Dont' save meta boxes for revisions or autosaves |
| 2689 |
if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
| 2690 |
return; |
| 2691 |
} |
| 2692 |
|
| 2693 |
// Check the nonce |
| 2694 |
if ( empty( $_POST['propertyhive_meta_nonce'] ) || ! wp_verify_nonce( $_POST['propertyhive_meta_nonce'], 'propertyhive_save_data' ) ) { |
| 2695 |
return; |
| 2696 |
} |
| 2697 |
|
| 2698 |
// Check the post being saved == the $post_id to prevent triggering this call for other save_post events |
| 2699 |
if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) { |
| 2700 |
return; |
| 2701 |
} |
| 2702 |
|
| 2703 |
// Check user has permission to edit |
| 2704 |
if ( ! current_user_can( 'edit_post', $post_id ) ) { |
| 2705 |
return; |
| 2706 |
} |
| 2707 |
|
| 2708 |
// Check the post type |
| 2709 |
if ( |
| 2710 |
! in_array( |
| 2711 |
$post->post_type, |
| 2712 |
apply_filters( 'propertyhive_post_types_with_tabs', array('property', 'contact', 'enquiry', 'appraisal', 'viewing', 'offer', 'sale', 'tenancy') ) |
| 2713 |
) |
| 2714 |
) { |
| 2715 |
return; |
| 2716 |
} |
| 2717 |
|
| 2718 |
if ( isset($_POST['post_parent']) && $_POST['post_parent'] != '' && $_POST['post_parent'] != '0' ) |
| 2719 |
{ |
| 2720 |
global $wpdb; |
| 2721 |
|
| 2722 |
$wpdb->update( $wpdb->posts, array( 'post_parent' => (int)$_POST['post_parent'] ), array( 'ID' => $post_id ) ); |
| 2723 |
} |
| 2724 |
|
| 2725 |
do_action( 'propertyhive_process_' . $post->post_type . '_meta', $post_id, $post ); |
| 2726 |
} |
| 2727 |
|
| 2728 |
} |
| 2729 |
|
| 2730 |
new PH_Admin_Meta_Boxes(); |
| 2731 |
|
| 2732 |
} |