diff --git a/admin/classes/pods-export-code-api.php b/admin/classes/pods-export-code-api.php index 0f7aba5..c880d89 100644 --- a/admin/classes/pods-export-code-api.php +++ b/admin/classes/pods-export-code-api.php @@ -88,8 +88,7 @@ public function export_pod( $pod_name ) { } } - $output .= sprintf( "\t\$group = %s;\n\n", $this->var_export_format( $group, 1 ) ); - $output .= "\tpods_register_group( \$group, \$pod['name'] );\n\n"; + $group_fields_to_export = []; // Output a pods_register_field() call for each field foreach ( $group_fields as $group_field ) { @@ -105,9 +104,12 @@ public function export_pod( $pod_name ) { } } - $output .= sprintf( "\t\$group_field = %s;\n\n", $this->var_export_format( $group_field, 1 ) ); - $output .= "\tpods_register_group_field( \$group_field, \$group['name'], \$pod['name'] );\n\n"; + $group_fields_to_export[ $group_field['name'] ] = $group_field; } + + $output .= sprintf( "\t\$group = %s;\n\n", $this->var_export_format( $group, 1 ) ); + $output .= sprintf( "\t\$group_fields = %s;\n\n", $this->var_export_format( $group_fields_to_export, 1 ) ); + $output .= "\tpods_register_group( \$group, \$pod['name'], \$group_fields );\n\n"; } return $output;