@@ -145,28 +145,53 @@ private function parse_banner( array $remote ): array {
145145 }
146146
147147 /**
148- * Parse a list of image items from a remote dataset.
148+ * Parse a list of features from a remote dataset.
149149 *
150150 * @param array $remote Remote data.
151151 *
152- * @return array[] Parsed image data
152+ * @return array[] Parsed feature data.
153153 */
154- private function parse_image_list ( array $ remote ): array {
155- $ items = [];
154+ private function parse_features ( array $ remote ): array {
155+ $ limit = max ( self ::ITEM_LIMIT , count ( $ remote ) );
156+ $ features = [];
157+
158+ for ( $ i = 0 ; $ i < $ limit ; $ i ++ ) {
159+ $ feature = $ remote [ $ i ];
160+
161+ $ features [] = [
162+ 'title ' => $ feature ['title ' ] ?? '' ,
163+ 'follow_url ' => $ feature ['follow_url ' ] ?? '' ,
164+ 'image_url ' => $ feature ['image_url ' ] ?? '' ,
165+ 'category ' => $ feature ['category ' ] ?? '' ,
166+ 'description ' => $ feature ['description ' ] ?? '' ,
167+ ];
168+ }
169+
170+ return $ features ;
171+ }
156172
173+ /**
174+ * Parse a list of partners from a remote dataset.
175+ *
176+ * @param array $remote Remote data.
177+ *
178+ * @return array[] Parsed partner data.
179+ */
180+ private function parse_partners ( array $ remote ): array {
157181 $ limit = max ( self ::ITEM_LIMIT , count ( $ remote ) );
182+ $ partners = [];
158183
159184 for ( $ i = 0 ; $ i < $ limit ; $ i ++ ) {
160- $ remote_item = $ remote [ $ i ];
185+ $ partner = $ remote [ $ i ];
161186
162- $ items [] = [
163- 'title ' => $ remote_item ['title ' ] ?? '' ,
164- 'follow_url ' => $ remote_item ['follow_url ' ] ?? '' ,
165- 'image_url ' => $ remote_item ['image_url ' ] ?? '' ,
187+ $ partners [] = [
188+ 'title ' => $ partner ['title ' ] ?? '' ,
189+ 'follow_url ' => $ partner ['follow_url ' ] ?? '' ,
190+ 'image_url ' => $ partner ['image_url ' ] ?? '' ,
166191 ];
167192 }
168193
169- return $ items ;
194+ return $ partners ;
170195 }
171196
172197 /**
@@ -176,6 +201,7 @@ private function parse_image_list( array $remote ): array {
176201 */
177202 protected function fetch_remote_welcome_data () {
178203 $ remote_welcome_data = wp_remote_get ( self ::WELCOME_JSON_URL );
204+
179205 if ( is_wp_error ( $ remote_welcome_data ) ) {
180206 return ;
181207 }
@@ -188,8 +214,8 @@ protected function fetch_remote_welcome_data() {
188214
189215 $ this ->welcome_data ['banner ' ] = $ this ->parse_banner ( self ::safe_get_array ( $ remote_welcome_data , 'banner ' ) );
190216 $ this ->welcome_data ['hero-item ' ] = $ this ->parse_hero_item ( self ::safe_get_array ( $ remote_welcome_data , 'hero-item ' ) );
191- $ this ->welcome_data ['features ' ] = $ this ->parse_image_list ( self ::safe_get_array ( $ remote_welcome_data , 'features ' ) );
192- $ this ->welcome_data ['partners ' ] = $ this ->parse_image_list ( self ::safe_get_array ( $ remote_welcome_data , 'partners ' ) );
217+ $ this ->welcome_data ['features ' ] = $ this ->parse_features ( self ::safe_get_array ( $ remote_welcome_data , 'features ' ) );
218+ $ this ->welcome_data ['partners ' ] = $ this ->parse_partners ( self ::safe_get_array ( $ remote_welcome_data , 'partners ' ) );
193219 }
194220
195221 /**
@@ -236,7 +262,7 @@ protected function build_changelog_data() {
236262
237263 foreach ( array_slice ( $ lines , 1 ) as $ line ) {
238264 $ entry = trim ( str_replace ( '(PRO) ' , '' , str_replace ( '* ' , '' , $ line ) ) );
239- $ core_or_pro = str_contains ( $ line , '(PRO) ' ) ? 'pro ' : 'core ' ;
265+ $ core_or_pro = false === strpos ( $ line , '(PRO) ' ) ? 'core ' : 'pro ' ;
240266
241267 if ( ! isset ( $ changelog [ $ version ][ $ section_type ] ) ) {
242268 $ changelog [ $ version ][ $ section_type ] = [
@@ -287,15 +313,17 @@ public function get_hero_item(): array {
287313 }
288314
289315 /**
290- * Retrieve the list of featured images retrieved from the remote API.
316+ * Retrieve the list of features retrieved from the remote API.
291317 *
292318 * @return array{
293319 * title: string,
294320 * follow_url: string,
295- * image_url: string
296- * }[] Featured image details.
321+ * image_url: string,
322+ * category: string,
323+ * description: string
324+ * }[] Feature details.
297325 */
298- public function get_featured_images (): array {
326+ public function get_features (): array {
299327 return $ this ->welcome_data ['features ' ] ?? [];
300328 }
301329
0 commit comments