diff --git a/includes/admin/core/class-admin-builder.php b/includes/admin/core/class-admin-builder.php index 243b4c33..e0b49050 100644 --- a/includes/admin/core/class-admin-builder.php +++ b/includes/admin/core/class-admin-builder.php @@ -366,8 +366,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) { * * @return string */ - function get_fields_by_row( $row_id ) { - + public function get_fields_by_row( $row_id ) { if ( empty( $this->global_fields ) || ! is_array( $this->global_fields ) ) { $this->global_fields = array(); } @@ -379,10 +378,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Builder' ) ) { } } - return ( isset ( $results ) ) ? $results : ''; + return isset( $results ) ? $results : ''; } - /** * Get fields by sub row * diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index b781b30d..2aa7a3b3 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -1,6 +1,8 @@ query()->get_attr( 'custom_fields', $form_id ); - $field_scope = UM()->builtin()->predefined_fields; + $fields = UM()->query()->get_attr( 'custom_fields', $form_id ); + if ( empty( $fields ) || ! is_array( $fields ) ) { + $fields = array(); + } if ( ! isset( $fields[ $global_id ] ) ) { + $field_scope = UM()->builtin()->predefined_fields; + $count = 1; if ( ! empty( $fields ) ) { $count = count( $fields ) + 1; @@ -1624,7 +1630,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { * @param $key * * @return mixed - * @throws \Exception + * @throws Exception */ public function get_field( $key ) { $fields = $this->get_fields(); @@ -2161,7 +2167,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { * @param array $args * * @return string|null - * @throws \Exception + * @throws Exception */ public function edit_field( $key, $data, $rule = false, $args = array() ) { global $_um_profile_id; @@ -4030,7 +4036,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) { return $arr; } - /** * Get fields in row * @@ -4038,8 +4043,8 @@ if ( ! class_exists( 'um\core\Fields' ) ) { * * @return string */ - function get_fields_by_row( $row_id ) { - if ( ! isset( $this->get_fields ) ) { + public function get_fields_by_row( $row_id ) { + if ( ! isset( $this->get_fields ) || ! is_array( $this->get_fields ) ) { return ''; } @@ -4049,10 +4054,9 @@ if ( ! class_exists( 'um\core\Fields' ) ) { } } - return ( isset ( $results ) ) ? $results : ''; + return isset( $results ) ? $results : ''; } - /** * Get fields by sub row * @@ -4119,7 +4123,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { * @param array $args * * @return string|null - * @throws \Exception + * @throws Exception */ public function display( $mode, $args ) { $output = null; @@ -4289,7 +4293,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { * @param bool $rule * * @return string|null - * @throws \Exception + * @throws Exception */ public function view_field( $key, $data, $rule = false ) { if ( '_um_last_login' === $key ) { @@ -4644,7 +4648,6 @@ if ( ! class_exists( 'um\core\Fields' ) ) { return apply_filters( "um_view_field_output_" . $data['type'], $data ); } - /** * Display fields ( view mode ) * @@ -4652,7 +4655,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { * @param array $args * * @return string|null - * @throws \Exception + * @throws Exception */ public function display_view( $mode, $args ) { $output = null; @@ -4664,7 +4667,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { $this->set_mode = $mode; $this->set_id = absint( $this->global_args['form_id'] ); - $this->field_icons = ( isset( $this->global_args['icons'] ) ) ? $this->global_args['icons'] : 'label'; + $this->field_icons = isset( $this->global_args['icons'] ) ? $this->global_args['icons'] : 'label'; // start output here $this->get_fields = $this->get_fields(); @@ -4694,8 +4697,7 @@ if ( ! class_exists( 'um\core\Fields' ) ) { } } - if ( ! empty( $this->get_fields ) ) { - + if ( ! empty( $this->get_fields ) && is_array( $this->get_fields ) ) { // find rows foreach ( $this->get_fields as $key => $array ) { if ( isset( $array['type'] ) && 'row' === $array['type'] ) {