diff --git a/includes/admin/core/class-admin-builder.php b/includes/admin/core/class-admin-builder.php index 8e9a4ccf..d48ec3db 100644 --- a/includes/admin/core/class-admin-builder.php +++ b/includes/admin/core/class-admin-builder.php @@ -391,7 +391,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) { return ''; } - foreach( $row_fields as $key => $array ) { + foreach ( $row_fields as $key => $array ) { if ( ! isset( $array['in_sub_row'] ) || ( isset( $array['in_sub_row'] ) && $array['in_sub_row'] == $subrow_id ) ) { $results[ $key ] = $array; unset( $this->global_fields[ $key ] ); @@ -401,18 +401,15 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) { return ( isset ( $results ) ) ? $results : ''; } - /** - * Display the builder + * Display the builder. */ - function show_builder() { - + public function show_builder() { $fields = UM()->query()->get_attr( 'custom_fields', $this->form_id ); - if ( !isset( $fields ) || empty( $fields ) ) { ?> - + if ( empty( $fields ) ) { + ?>
- global_fields = array(); - } else { - $this->global_fields = $fields; - } - - foreach ( $this->global_fields as $key => $array ) { - if ( $array['type'] == 'row' ) { - $rows[ $key ] = $array; - unset( $this->global_fields[ $key ] ); // not needed now + $rows = array(); + $this->global_fields = is_array( $fields ) ? $fields : array(); + foreach ( $this->global_fields as $key => $field_data ) { + if ( array_key_exists( 'type', $field_data ) && 'row' === $field_data['type'] ) { + $rows[ $key ] = $field_data; + unset( $this->global_fields[ $key ] ); // Remove rows from global fields because not needed below. } - } - if ( ! isset( $rows ) ) { + // Set 1st row if there aren't any rows in form. + if ( empty( $rows ) ) { $rows = array( '_um_row_1' => array( - 'type' => 'row', - 'id' => '_um_row_1', - 'sub_rows' => 1, - 'cols' => 1 + 'type' => 'row', + 'id' => '_um_row_1', + 'sub_rows' => 1, + 'cols' => 1, ), ); } - foreach ( $rows as $row_id => $array ) { ?> - + foreach ( $rows as $row_id => $array ) { + ?>