Post.php
40 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AC\Relation; |
| 4 | |
| 5 | use AC\Relation; |
| 6 | use WP_Post_Type; |
| 7 | |
| 8 | class Post extends Relation { |
| 9 | |
| 10 | /** |
| 11 | * @var object |
| 12 | */ |
| 13 | private $post_type_object; |
| 14 | |
| 15 | public function __construct( $id ) { |
| 16 | parent::__construct( $id ); |
| 17 | |
| 18 | $this->post_type_object = get_post_type_object( $this->get_id() ); |
| 19 | } |
| 20 | |
| 21 | public function get_type() { |
| 22 | return 'post'; |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * @return WP_Post_Type |
| 27 | */ |
| 28 | public function get_post_type_object() { |
| 29 | return $this->post_type_object; |
| 30 | } |
| 31 | |
| 32 | public function get_labels() { |
| 33 | if ( ! $this->post_type_object ) { |
| 34 | return false; |
| 35 | } |
| 36 | |
| 37 | return $this->post_type_object->labels; |
| 38 | } |
| 39 | |
| 40 | } |