type. * If more than one setting has the same id then the returned array is id => array of types. * * @param array $settings The settings to transform. * * @return array The transformed settings. */ public function get_ids_and_types( $settings ) { $settings_ids_and_types = array(); foreach ( $settings as $setting ) { $id = array_key_exists( 'id', $setting ) ? $setting['id'] : null; $type = $setting['type']; if ( ! array_key_exists( $id, $settings_ids_and_types ) ) { $settings_ids_and_types[ $id ] = $type; } elseif ( is_array( $settings_ids_and_types[ $id ] ) ) { $settings_ids_and_types[ $id ][] = $type; } else { $settings_ids_and_types[ $id ] = array( $settings_ids_and_types[ $id ], $type ); } } return $settings_ids_and_types; } }