# betterdocs/2.5.2/includes/Admin/Builder/GlobalFields.php

BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ &amp; Chatbot, version 2.5.2. 48 lines.

- Page: https://pluginprobe.com/plugins/betterdocs/2.5.2/code/includes/Admin/Builder/GlobalFields.php
- Raw: https://pluginprobe.com/plugins/betterdocs/2.5.2/raw/includes/Admin/Builder/GlobalFields.php
- Modified: 2023-08-14T08:41:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/betterdocs/2.5.2/code/includes/Admin/Builder/GlobalFields.php#L10-L20`.

```php
<?php

namespace WPDeveloper\BetterDocs\Admin\Builder;

class GlobalFields {
    public static function normalize_fields( $fields, $key = '', $value = [], $return = [] ) {
        foreach ( $fields as $val => $label ) {
            if ( empty( $return[$val] ) && ! is_array( $label ) ) {
                $return[$val] = [
                    'value' => $val,
                    'label' => $label
                ];
            } elseif ( empty( $return[$val] ) ) {
                $return[$val] = $label;
            }
            if ( ! empty( $key ) ) {
                $return[$val] = Rules::includes( $key, $value, false, $return[$val] );
            }
        }

        return $return;
    }

    public static function normalize( $arr ) {

        if ( ! empty( $arr['fields'] ) ) {
            $arr['fields'] = array_values( $arr['fields'] );
        }

        if ( ! empty( $arr['options'] ) ) {
            $arr['options'] = array_values( $arr['options'] );
        }

        if ( ! empty( $arr['tabs'] ) ) {
            $arr['tabs'] = array_values( $arr['tabs'] );
        }

        if ( is_array( $arr ) ) {
            foreach ( $arr as $key => $value ) {
                if ( is_array( $value ) ) {
                    $arr[$key] = self::normalize( $value );
                }
            }
        }
        return $arr;
    }
}

```
