@@ -10,52 +10,22 @@ class Post
1010
1111 protected $ WP_Post ;
1212
13- /**
14- * @var string
15- */
16- protected $ title = '' ;
13+ protected $ options = [
14+ ' thumbnail_size ' => ' post-thumbnail ' ,
15+ ' thumbnail_classes ' => '' ,
16+ ] ;
1717
18- /**
19- * @var string
20- */
18+ protected $ title = '' ;
2119 protected $ url = '' ;
22-
23- /**
24- * @var string
25- */
2620 protected $ slug = '' ;
27-
28- /**
29- * @var string
30- */
3121 protected $ content = '' ;
32-
33- /**
34- * @var string
35- */
3622 protected $ status = '' ;
37-
38- /**
39- * @var string
40- */
4123 protected $ format = '' ;
42-
43- /**
44- * @var string
45- */
4624 protected $ excerpt = '' ;
47-
48- /**
49- * @var string
50- */
5125 protected $ date = '' ;
52-
53- /**
54- * @var string
55- */
5626 protected $ dateModified = '' ;
57-
5827 protected $ parent ;
28+ protected $ thumbnail = '' ;
5929
6030 /**
6131 * Set up
@@ -71,24 +41,44 @@ public function __construct(int $id)
7141 return ;
7242 }
7343
74- $ this ->title = \get_the_title ($ this ->WP_Post );
75- $ this ->url = \get_permalink ($ this ->WP_Post );
76- $ this ->slug = $ this ->WP_Post ->post_name ;
77- $ this ->content = $ this ->WP_Post ->post_content ;
78- $ this ->status = $ this ->WP_Post ->post_status ;
79- $ this ->format = \get_post_format ($ this ->WP_Post ) ?: 'standard ' ;
80- $ this ->excerpt = \get_the_excerpt ($ this ->WP_Post );
81- $ this ->date = $ this ->WP_Post ->post_date ;
82- $ this ->dateModified = $ this ->WP_Post ->post_modified ;
83- $ this ->parent = new self ($ this ->WP_Post ->post_parent );
44+ $ this ->title = \get_the_title ($ this ->WPPost ());
45+ $ this ->url = \get_permalink ($ this ->WPPost ());
46+ $ this ->slug = $ this ->WPPost ()->post_name ;
47+ $ this ->content = $ this ->WPPost ()->post_content ;
48+ $ this ->status = $ this ->WPPost ()->post_status ;
49+ $ this ->format = \get_post_format ($ this ->WPPost ()) ?: 'standard ' ;
50+ $ this ->excerpt = \get_the_excerpt ($ this ->WPPost ());
51+ $ this ->date = $ this ->WPPost ()->post_date ;
52+ $ this ->dateModified = $ this ->WPPost ()->post_modified ;
53+ $ this ->parent = new self ($ this ->WPPost ()->post_parent );
54+ }
55+
56+ public function setOption (string $ key , $ value )
57+ {
58+ if (isset ($ this ->options [$ key ])) {
59+ $ this ->options [$ key ] = $ value ;
60+ }
61+
62+ return $ this ;
63+ }
64+
65+ public function withThumbnail ()
66+ {
67+ $ this ->thumbnail = \get_the_post_thumbnail (
68+ $ this ->WPPost (),
69+ $ this ->options ['thumbnail_size ' ],
70+ $ this ->options ['thumbnail_classes ' ]
71+ );
72+
73+ return $ this ;
8474 }
8575
8676 public function id ()
8777 {
8878 return $ this ->id ;
8979 }
9080
91- public function WP_Post ()
81+ public function WPPost ()
9282 {
9383 return $ this ->WP_Post ;
9484 }
0 commit comments