File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212 */
1313class Page_Types {
1414
15+ /**
16+ * The page types.
17+ *
18+ * @var array
19+ */
20+ public static $ page_types = [];
21+
1522 /**
1623 * The taxonomy name.
1724 *
@@ -145,9 +152,8 @@ public function maybe_update_terms() {
145152 * @return array
146153 */
147154 public function get_page_types () {
148- static $ page_types ;
149- if ( null !== $ page_types ) {
150- return $ page_types ;
155+ if ( null !== static ::$ page_types ) {
156+ return static ::$ page_types ;
151157 }
152158
153159 $ terms = \get_terms (
@@ -158,21 +164,21 @@ public function get_page_types() {
158164 );
159165
160166 if ( ! $ terms || \is_wp_error ( $ terms ) ) {
161- $ page_types = [];
162- return $ page_types ;
167+ static :: $ page_types = [];
168+ return static :: $ page_types ;
163169 }
164170
165- $ page_types = [];
171+ static :: $ page_types = [];
166172 foreach ( $ terms as $ term ) {
167- $ page_types [] = [
173+ static :: $ page_types [] = [
168174 'id ' => $ term ->term_id ,
169175 'slug ' => $ term ->slug ,
170176 'title ' => $ term ->name ,
171177 'description ' => $ term ->description ,
172178 ];
173179 }
174180
175- return $ page_types ;
181+ return static :: $ page_types ;
176182 }
177183
178184 /**
Original file line number Diff line number Diff line change @@ -121,6 +121,10 @@ public function test_maybe_update_terms() {
121121 * @return void
122122 */
123123 public function test_get_page_types () {
124+ // Reset the page types, before the test.
125+ $ page_types_object = \progress_planner ()->get_page_types ();
126+ $ page_types_object ::$ page_types = null ;
127+
124128 $ page_types = \progress_planner ()->get_page_types ()->get_page_types ();
125129 $ lessons = self ::get_lessons ();
126130 $ this ->assertCount ( \count ( $ lessons ), $ page_types );
You can’t perform that action at this time.
0 commit comments