@@ 79-86 (lines=8) @@ | ||
76 | * |
|
77 | * @return static |
|
78 | */ |
|
79 | public static function fromID($id) |
|
80 | { |
|
81 | if (! $term = get_term_by('id', (int) $id, static::TAXONOMY)) { |
|
82 | throw new TermNotFoundException("No term found with ID $id."); |
|
83 | } |
|
84 | ||
85 | return static::fromWpTerm($term); |
|
86 | } |
|
87 | ||
88 | /** |
|
89 | * Create a new instance from a slug. |
|
@@ 95-102 (lines=8) @@ | ||
92 | * |
|
93 | * @return static |
|
94 | */ |
|
95 | public static function fromSlug($slug) |
|
96 | { |
|
97 | if (! $term = get_term_by('slug', $slug, static::TAXONOMY)) { |
|
98 | throw new TermNotFoundException("No term found with slug '$slug'."); |
|
99 | } |
|
100 | ||
101 | return static::fromWpTerm($term); |
|
102 | } |
|
103 | ||
104 | /** |
|
105 | * Create a new instance from an array of attributes. |