From 4751e0b063723a812dcd650da72b482752afff3e Mon Sep 17 00:00:00 2001 From: Anthony Budd Date: Wed, 14 Jun 2017 14:14:35 +0100 Subject: [PATCH] the_content is a v.prop that outputs a filtered content --- src/WP_Model.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/WP_Model.php b/src/WP_Model.php index 62b501f..fc18c8a 100644 --- a/src/WP_Model.php +++ b/src/WP_Model.php @@ -229,7 +229,7 @@ public static function extract($array, $column) private function getAttributes() { - return array_merge($this->attributes, ['title', 'content']); + return array_merge($this->attributes, ['title', 'content', 'the_content']); } /** @@ -400,7 +400,15 @@ public function deleteMeta($key) public function get($attribute, $default = NULL) { if(isset($this->data[$attribute])){ - return $this->data[$attribute]; + switch($attribute){ + case 'the_content': + return apply_filters('the_content', $this->data[$attribute]); + break; + + default: + return $this->data[$attribute]; + break; + } } return $default; @@ -639,7 +647,7 @@ public function toArray() if(!empty($this->protected) && !in_array($attribute, $this->protected)){ // Do not add to $model }else{ - $model[$attribute] = $this->get($attribute); + $model[$attribute] = $this->$attribute; } } @@ -660,6 +668,10 @@ public function toArray() return $model; } + public function postDate($format = 'd-m-Y'){ + return date($format, strtotime($this->_post->post_date)); + } + /** * Get the model for a single page or in the loop *