| | 1 | <?php |
| | 2 | |
| | 3 | class WP_Post { |
| | 4 | public $ID; |
| | 5 | public $post_author; |
| | 6 | public $post_date; |
| | 7 | public $post_date_gmt; |
| | 8 | public $post_content; |
| | 9 | public $post_title; |
| | 10 | public $post_excerpt; |
| | 11 | public $post_status; |
| | 12 | public $comment_status; |
| | 13 | public $ping_status; |
| | 14 | public $post_password; |
| | 15 | public $post_name; |
| | 16 | public $to_ping; |
| | 17 | public $pinged; |
| | 18 | public $post_modified; |
| | 19 | public $post_modified_gmt; |
| | 20 | public $post_content_filtered; |
| | 21 | public $post_parent; |
| | 22 | public $guid; |
| | 23 | public $menu_order; |
| | 24 | public $post_type; |
| | 25 | public $post_mime_type; |
| | 26 | public $comment_count; |
| | 27 | public $filter; |
| | 28 | |
| | 29 | public function __set( $name, $value ) { |
| | 30 | if ( property_exists('WP_Post', $name) ) { |
| | 31 | $this->$name = $value; |
| | 32 | return $this->$name; |
| | 33 | } |
| | 34 | |
| | 35 | return false; |
| | 36 | } |
| | 37 | |
| | 38 | public static function get_instance( $post_data ) { |
| | 39 | $post = new WP_Post(); |
| | 40 | |
| | 41 | foreach ( $post_data as $k=>$v ) { |
| | 42 | if ( property_exists('WP_Post', $k) ) { |
| | 43 | $post->$k = $v; |
| | 44 | } |
| | 45 | } |
| | 46 | |
| | 47 | return $post; |
| | 48 | } |
| | 49 | |
| | 50 | // wrapper for get_the_title() |
| | 51 | // the idea is to add wrappers for the other functions related |
| | 52 | // to displaying post info as well |
| | 53 | public function get_the_title() { |
| | 54 | return get_the_title($this); |
| | 55 | } |
| | 56 | } |