Skip to content

Commit e1ce461

Browse files
author
Petter Walbø Johnsgård
authored
Merge pull request #37 from DekodeInteraktiv/iss35
Revert to strict array argument, validate input as array.
2 parents 5915504 + 969c077 commit e1ce461

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

class-grid.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,12 @@ public function add_wrapper_classname( array $classnames, Module $module ) : arr
293293
*/
294294
public function load_args_from_layout_content( array $raw_content, int $counter = 0 ) {
295295

296-
$this->collection = $this->structure_card_data( $raw_content['flex_grid'] );
296+
$this->collection = [];
297+
298+
if ( is_array( $raw_content['flex_grid'] ) ) {
299+
$this->collection = $this->structure_card_data( $raw_content['flex_grid'] );
300+
}
301+
297302
$this->text_align = (string) apply_filters( 'hogan/module/grid/template/text-align', 'center' );
298303
$this->theme = $raw_content['theme'] ?? '';
299304
parent::load_args_from_layout_content( $raw_content, $counter );
@@ -303,19 +308,19 @@ public function load_args_from_layout_content( array $raw_content, int $counter
303308
/**
304309
* Get card layouts
305310
*
306-
* @param bool|array $data ACF layouts.
311+
* @param array $data ACF layouts.
307312
* @return array Cards collection
308313
*/
309-
public function structure_card_data( $data ) : array {
310-
311-
if ( empty( $data ) ) {
312-
return [];
313-
}
314+
public function structure_card_data( array $data ) : array {
314315

315316
$cards = [];
316317

317318
foreach ( $data as $group ) {
318319

320+
if ( ! isset( $group['acf_fc_layout'] ) ) {
321+
continue;
322+
}
323+
319324
switch ( $group['acf_fc_layout'] ) {
320325

321326
case 'static_content':

0 commit comments

Comments
 (0)