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 ) ) { + ?>
-
@@ -420,204 +417,158 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) {
-
-
-
- -
- -
- +
-
-
-
- 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 ) { + ?>
-
- + - + -
- +
+
+ get_fields_by_row( $row_id ); + $sub_rows = array_key_exists( 'sub_rows', $array ) ? $array['sub_rows'] : 1; - get_fields_by_row( $row_id ); - - $sub_rows = ( isset( $array['sub_rows'] ) ) ? $array['sub_rows'] : 1; - for ( $c = 0; $c < $sub_rows; $c++ ) { - + for ( $c = 0; $c < $sub_rows; $c++ ) { $subrow_fields = $this->get_fields_in_subrow( $row_fields, $c ); - ?> -
-
- '; + $col_class = ( $col_num === $i ) ? 'active' : ''; + ?> + + -
-
- 0 ) { ?> + 0 ) { ?> + +
-
- array_sort_by_column( $subrow_fields, 'position' ); + foreach ( $subrow_fields as $key => $keyarray ) { + if ( ! array_key_exists( 'type', $keyarray ) || ! array_key_exists( 'title', $keyarray ) ) { + continue; + } - $subrow_fields = $this->array_sort_by_column( $subrow_fields, 'position'); - - foreach( $subrow_fields as $key => $keyarray ) { - /** - * @var $type - * @var $title - */ - extract( $keyarray ); - + $field_type = $keyarray['type']; + $field_title = $keyarray['title']; + $in_group = array_key_exists( 'in_group', $keyarray ) ? $keyarray['in_group'] : ''; + $in_column = array_key_exists( 'in_column', $keyarray ) ? $keyarray['in_column'] : 1; + $icon = array_key_exists( 'icon', $keyarray ) ? $keyarray['icon'] : ''; + $field_name = __( 'Invalid field type', 'ultimate-member' ); + if ( array_key_exists( $field_type, UM()->builtin()->core_fields ) && array_key_exists( 'name', UM()->builtin()->core_fields[ $field_type ] ) ) { + $field_name = UM()->builtin()->core_fields[ $field_type ]['name']; + } ?> - -
- -
- +
+
+ - - -
- builtin()->core_fields[$type]['name'] ) ? UM()->builtin()->core_fields[$type]['name'] : ''; ?> -
-
- - - - - - - - - - - - + + - -
- - -
- -
+ +
+
+
+ + + + + + + +
+
+ +
-
- -
-
-
-
- - - +
-
- get_results( - "SELECT * - FROM {$wpdb->posts} - WHERE post_type = 'page' AND + "SELECT * + FROM {$wpdb->posts} + WHERE post_type = 'page' AND post_status = 'publish'", OBJECT ); @@ -363,21 +363,18 @@ if ( ! class_exists( 'um\core\Query' ) ) { update_post_meta( $post_id, '_um_' . $key, $new_value ); } - /** - * Get data + * Get postmeta related to Ultimate Member. * - * @param $key - * @param $post_id + * @param string $key + * @param int $post_id * * @return mixed */ - function get_attr( $key, $post_id ) { - $meta = get_post_meta( $post_id, '_um_' . $key, true ); - return $meta; + public function get_attr( $key, $post_id ) { + return get_post_meta( $post_id, '_um_' . $key, true ); } - /** * Delete data *