File tree Expand file tree Collapse file tree 4 files changed +80
-3
lines changed
Expand file tree Collapse file tree 4 files changed +80
-3
lines changed Original file line number Diff line number Diff line change 66
77class Post
88{
9- public $ id ;
9+ public int $ id ;
1010
1111 protected \WP_Post $ WP_Post ;
1212
@@ -22,7 +22,7 @@ class Post
2222 public \WP_Post $ parent ;
2323 public string $ thumbnailHtml = '' ;
2424
25- public function __construct (int $ id = 0 )
25+ public function __construct (int $ id )
2626 {
2727 $ this ->id = $ id ;
2828
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace OOPWP \Terms ;
4+
5+ class Category extends Term
6+ {
7+ public string $ taxonomyName = 'category ' ;
8+
9+ public function __construct (int $ id )
10+ {
11+ parent ::__construct ($ id , $ this ->taxonomyName );
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace OOPWP \Terms ;
4+
5+ class Term
6+ {
7+ public int $ id ;
8+
9+ public string $ taxonomy ;
10+
11+ protected \WP_Term $ WP_Term ;
12+
13+ public string $ name = '' ;
14+ public string $ slug = '' ;
15+ public string $ description = '' ;
16+ public self $ parent ;
17+
18+ public function __construct (int $ id , string $ taxonomy )
19+ {
20+ $ this ->id = $ id ;
21+ $ this ->taxonomy = $ taxonomy ;
22+
23+ $ this ->WP_Term = \get_term ($ this ->id , $ this ->taxonomy );
24+ }
25+
26+ public function withAll ()
27+ {
28+ $ this
29+ ->withName ()
30+ ->withSlug ()
31+ ->withDescription ()
32+ ->withParent ();
33+
34+ return $ this ;
35+ }
36+
37+ public function withName ()
38+ {
39+ $ this ->name = $ this ->WP_Term ->name ;
40+
41+ return $ this ;
42+ }
43+
44+ public function withSlug ()
45+ {
46+ $ this ->slug = $ this ->WP_Term ->slug ;
47+
48+ return $ this ;
49+ }
50+
51+ public function withDescription ()
52+ {
53+ $ this ->description = $ this ->WP_Term ->description ;
54+
55+ return $ this ;
56+ }
57+
58+ public function withParent ()
59+ {
60+ $ this ->parent = new self ($ this ->WP_Term ->parent , $ this ->taxonomy );
61+
62+ return $ this ;
63+ }
64+ }
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ class User
2222 public string $ nickname = '' ;
2323 public string $ description = '' ;
2424
25- public function __construct (int $ id = 0 )
25+ public function __construct (int $ id )
2626 {
2727 $ this ->id = $ id ;
2828
You can’t perform that action at this time.
0 commit comments