@@ -15,15 +15,15 @@ class Post
1515 'thumbnail_classes ' => '' ,
1616 ];
1717
18- public string $ title = '' ;
19- public string $ url = '' ;
20- public string $ slug = '' ;
18+ public string $ title = '' ;
19+ public string $ url = '' ;
20+ public string $ slug = '' ;
2121 public string $ content = '' ;
22- public string $ status = '' ;
23- public string $ format = '' ;
22+ public string $ status = '' ;
23+ public string $ format = '' ;
2424 public string $ excerpt = '' ;
2525 public Carbon $ date ;
26- public Carbon $ dateModified = '' ;
26+ public Carbon $ dateModified ;
2727 public \WP_Post $ parent ;
2828 public string $ thumbnail = '' ;
2929
@@ -34,110 +34,33 @@ class Post
3434 */
3535 public function __construct (int $ id )
3636 {
37- $ this ->id = $ id ?: - 1 ;
38- $ this ->WP_Post = \get_post ($ this ->id () );
37+ $ this ->id = $ id ?: 0 ;
38+ $ this ->WP_Post = \get_post ($ this ->id );
3939
4040 if (!$ this ->WP_Post ) {
4141 return ;
4242 }
4343
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 ;
44+ $ this ->title = \get_the_title ($ this ->WP_Post );
45+ $ this ->url = \get_permalink ($ this ->WP_Post );
46+ $ this ->slug = $ this ->WP_Post ->post_name ;
47+ $ this ->content = \apply_filters ('the_content ' , $ this ->WP_Post ->post_content );
48+ $ this ->status = $ this ->WP_Post ->post_status ;
49+ $ this ->format = \get_post_format ($ this ->WP_Post ) ?: 'standard ' ;
50+ $ this ->excerpt = \get_the_excerpt ($ this ->WP_Post );
51+ $ this ->date = new Carbon ($ this ->WP_Post ->post_date );
52+ $ this ->dateModified = new Carbon ($ this ->WP_Post ->post_modified );
53+ $ this ->parent = new self ($ this ->WP_Post ->post_parent );
6354 }
6455
6556 public function withThumbnail ()
6657 {
6758 $ this ->thumbnail = \get_the_post_thumbnail (
68- $ this ->WPPost () ,
59+ $ this ->WP_Post ,
6960 $ this ->options ['thumbnail_size ' ],
7061 $ this ->options ['thumbnail_classes ' ]
7162 );
7263
7364 return $ this ;
7465 }
75-
76- public function id ()
77- {
78- return $ this ->id ;
79- }
80-
81- public function WPPost ()
82- {
83- return $ this ->WP_Post ;
84- }
85-
86- public function url ()
87- {
88- return $ this ->url ;
89- }
90-
91- public function slug ()
92- {
93- return $ this ->slug ;
94- }
95-
96- public function status ()
97- {
98- return $ this ->status ;
99- }
100-
101- public function format ()
102- {
103- return $ this ->format ;
104- }
105-
106- public function title ()
107- {
108- return $ this ->title ;
109- }
110-
111- public function excerpt ()
112- {
113- return $ this ->excerpt ;
114- }
115-
116- public function date ()
117- {
118- return new Carbon ($ this ->date );
119- }
120-
121- public function modifiedDate ()
122- {
123- return new Carbon ($ this ->dateModified );
124- }
125-
126- /**
127- * @return string
128- */
129- public function content ()
130- {
131- return \apply_filters ('the_content ' , $ this ->content );
132- }
133-
134- public function parent ()
135- {
136- return $ this ->parent ;
137- }
138-
139- public function thumbnail ()
140- {
141- return $ this ->thumbnail ;
142- }
14366}
0 commit comments