PluginProbe
Property Hive / 2.2.6
Property Hive v2.2.6
2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 1.4.62 All 260 releases
propertyhive / includes / class-ph-key-date.php

class-ph-key-date.php in Property Hive 2.2.6, at includes/class-ph-key-date.php

100 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) )
4 {
5 // Exit if accessed directly
6 exit;
7 }
8
9 class PH_Key_Date {
10
11 /** @var int */
12 public $id;
13
14 /** @var string */
15 private $description;
16
17 public function __construct( WP_Post $post ) {
18 $this->id = $post->ID;
19 $this->description = $post->post_title;
20 }
21
22 public function description() {
23 return $this->description;
24 }
25
26 public function notes() {
27 return $this->_key_date_notes;
28 }
29
30 public function property() {
31 return new PH_Property(get_post($this->_property_id));
32 }
33
34 public function tenancy() {
35 return new PH_Tenancy($this->_tenancy_id);
36 }
37
38 public function date_due() {
39 return new DateTime($this->_date_due);
40 }
41
42 public function key_date_type_id() {
43 return $this->_key_date_type_id;
44 }
45
46 public function status() {
47
48 switch ($this->_key_date_status)
49 {
50 case 'pending':
51
52 $overdue_threshold = ( date_format($this->date_due(), 'H:i') == '00:00' ) ? 'Today' : 'Now';
53 switch(true)
54 {
55 case $this->date_due() < new DateTime($overdue_threshold):
56 return 'overdue';
57 case $this->date_due() <= new DateTime('+ ' . apply_filters( 'propertyhive_key_date_upcoming_days', 7 ) . ' DAYS'):
58 return 'upcoming';
59 default:
60 return 'pending';
61 }
62 case 'booked':
63 case 'complete':
64 default:
65 return $this->_key_date_status;
66 }
67 }
68
69 /**
70 * __isset function.
71 *
72 * @access public
73 * @param mixed $key
74 * @return bool
75 */
76 public function __isset( $key ) {
77 if ( ! $this->id ) {
78 return false;
79 }
80 return metadata_exists( 'post', $this->id, '_' . $key );
81 }
82
83 /**
84 * __get function.
85 *
86 * @access public
87 * @param mixed $key
88 * @return mixed
89 */
90 public function __get( $key ) {
91 // Get values or default if not set
92 $value = get_post_meta( $this->id, $key, true );
93 if ($value == '')
94 {
95 $value = get_post_meta( $this->id, '_' . $key, true );
96 }
97 return $value;
98 }
99 }
100