From aa31932d67f88a3ae70e5bd0fe15363504db158f Mon Sep 17 00:00:00 2001 From: Stefano Azzolini Date: Wed, 25 Feb 2015 15:01:23 +0100 Subject: [PATCH] Added AeriaPostRaw for fast post manipulation --- classes/AeriaPostRaw.php | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 classes/AeriaPostRaw.php diff --git a/classes/AeriaPostRaw.php b/classes/AeriaPostRaw.php new file mode 100644 index 0000000..8786785 --- /dev/null +++ b/classes/AeriaPostRaw.php @@ -0,0 +1,50 @@ +$id,'post_type'=>$type):array($fld=>$id); + $t_post = is_numeric($id)?get_post($id):current(get_posts($q)); + } + $this->id = $t_post->ID; + $this->title = $t_post->post_title; + $this->raw_content = $t_post->post_content; + $this->content = $t_post->post_content; + $this->excerpt = $t_post->post_excerpt; + $this->date = $t_post->post_date; + $this->slug = $t_post->post_name; + $this->order = $t_post->menu_order?:0; + $this->permalink = AERIA_HOME_URL.$t_post->post_type.'/'.$t_post->post_name; + $this->type = $type?:$t_post->post_type; + $this->parent = ($t_post->post_parent)?new self($t_post->post_parent):null; + } + } + + public function loadAsPage($id){ + if($id){ + if(is_a($id,'WP_Post')){ + $t_post = $id; + } else { + $t_post = is_numeric($id)?get_page($id):get_page_by_path($id); + } + + $this->id = $t_post->ID; + $this->title = $t_post->post_title; + $this->content = $t_post->post_content; + $this->excerpt = $t_post->post_excerpt; + $this->date = $t_post->post_date; + $this->slug = $t_post->post_name; + $this->order = $t_post->menu_order; + $this->permalink = AERIA_HOME_URL.$t_post->post_name; + $this->type = 'page'; + } + return $this; + } + +}