From 9546c1c7c43e4285c19f2ebc4889d96f35cb94df Mon Sep 17 00:00:00 2001 From: Rafael Mejia Date: Wed, 15 Jan 2020 16:56:30 -0500 Subject: [PATCH] Fixed PHP notice for accessing keys in array without verifying their existence. --- includes/acf-field-functions.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/includes/acf-field-functions.php b/includes/acf-field-functions.php index f0e48644..9717b834 100644 --- a/includes/acf-field-functions.php +++ b/includes/acf-field-functions.php @@ -349,18 +349,20 @@ function acf_get_fields( $parent ) { // Vars. $fields = array(); - // Check local fields first. - if( acf_have_local_fields($parent['key']) ) { - $raw_fields = acf_get_local_fields( $parent['key'] ); - foreach( $raw_fields as $raw_field ) { - $fields[] = acf_get_field( $raw_field['key'] ); - } - - // Then check database. - } else { - $raw_fields = acf_get_raw_fields( $parent['ID'] ); - foreach( $raw_fields as $raw_field ) { - $fields[] = acf_get_field( $raw_field['ID'] ); + if ( isset($parent['key'], $parent['ID']) ) { + // Check local fields first. + if( acf_have_local_fields($parent['key']) ) { + $raw_fields = acf_get_local_fields( $parent['key'] ); + foreach( $raw_fields as $raw_field ) { + $fields[] = acf_get_field( $raw_field['key'] ); + } + + // Then check database. + } else { + $raw_fields = acf_get_raw_fields( $parent['ID'] ); + foreach( $raw_fields as $raw_field ) { + $fields[] = acf_get_field( $raw_field['ID'] ); + } } }