| @@ -2,46 +2,46 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace WPDeveloper\BetterDocs\Admin\Builder; |
| 4 | 4 | |
| 5 | 5 | class GlobalFields { |
| 6 | - public static function normalize_fields( $fields, $key = '', $value = [], $return = [] ) { | |
| 7 | - foreach ( $fields as $val => $label ) { | |
| 8 | - if ( empty( $return[$val] ) && ! is_array( $label ) ) { | |
| 9 | - $return[$val] = [ | |
| 10 | - 'value' => $val, | |
| 11 | - 'label' => $label | |
| 12 | - ]; | |
| 13 | - } elseif ( empty( $return[$val] ) ) { | |
| 14 | - $return[$val] = $label; | |
| 15 | - } | |
| 16 | - if ( ! empty( $key ) ) { | |
| 17 | - $return[$val] = Rules::includes( $key, $value, false, $return[$val] ); | |
| 18 | - } | |
| 19 | - } | |
| 6 | + public static function normalize_fields( $fields, $key = '', $value = [], $return = [] ) { | |
| 7 | + foreach ( $fields as $val => $label ) { | |
| 8 | + if ( empty( $return[ $val ] ) && ! is_array( $label ) ) { | |
| 9 | + $return[ $val ] = [ | |
| 10 | + 'value' => $val, | |
| 11 | + 'label' => $label | |
| 12 | + ]; | |
| 13 | + } elseif ( empty( $return[ $val ] ) ) { | |
| 14 | + $return[ $val ] = $label; | |
| 15 | + } | |
| 16 | + if ( ! empty( $key ) ) { | |
| 17 | + $return[ $val ] = Rules::includes( $key, $value, false, $return[ $val ] ); | |
| 18 | + } | |
| 19 | + } | |
| 20 | 20 | |
| 21 | - return $return; | |
| 22 | - } | |
| 21 | + return $return; | |
| 22 | + } | |
| 23 | 23 | |
| 24 | - public static function normalize( $arr ) { | |
| 24 | + public static function normalize( $arr ) { | |
| 25 | 25 | |
| 26 | - if ( ! empty( $arr['fields'] ) ) { | |
| 27 | - $arr['fields'] = array_values( $arr['fields'] ); | |
| 28 | - } | |
| 26 | + if ( ! empty( $arr['fields'] ) ) { | |
| 27 | + $arr['fields'] = array_values( $arr['fields'] ); | |
| 28 | + } | |
| 29 | 29 | |
| 30 | - if ( ! empty( $arr['options'] ) ) { | |
| 31 | - $arr['options'] = array_values( $arr['options'] ); | |
| 32 | - } | |
| 30 | + if ( ! empty( $arr['options'] ) ) { | |
| 31 | + $arr['options'] = array_values( $arr['options'] ); | |
| 32 | + } | |
| 33 | 33 | |
| 34 | - if ( ! empty( $arr['tabs'] ) ) { | |
| 35 | - $arr['tabs'] = array_values( $arr['tabs'] ); | |
| 36 | - } | |
| 34 | + if ( ! empty( $arr['tabs'] ) ) { | |
| 35 | + $arr['tabs'] = array_values( $arr['tabs'] ); | |
| 36 | + } | |
| 37 | 37 | |
| 38 | - if ( is_array( $arr ) ) { | |
| 39 | - foreach ( $arr as $key => $value ) { | |
| 40 | - if ( is_array( $value ) ) { | |
| 41 | - $arr[$key] = self::normalize( $value ); | |
| 42 | - } | |
| 43 | - } | |
| 44 | - } | |
| 45 | - return $arr; | |
| 46 | - } | |
| 38 | + if ( is_array( $arr ) ) { | |
| 39 | + foreach ( $arr as $key => $value ) { | |
| 40 | + if ( is_array( $value ) ) { | |
| 41 | + $arr[ $key ] = self::normalize( $value ); | |
| 42 | + } | |
| 43 | + } | |
| 44 | + } | |
| 45 | + return $arr; | |
| 46 | + } | |
| 47 | 47 | } |