Skip to content

Commit

Permalink
the_content is a v.prop that outputs a filtered content
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonybudd committed Jun 14, 2017
1 parent ab6de22 commit 4751e0b
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/WP_Model.php
Original file line number Diff line number Diff line change
@@ -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
*

0 comments on commit 4751e0b

Please sign in to comment.