schema() ); if ( $encode === true ) { return $description; } // Convert the processed schema to a JSON-like string return wp_json_encode( $description, JSON_PRETTY_PRINT ); } /** * Recursive function that will crawl through the schema, * and call on itself to process each sub-item. * * @param mixed $item The item to process. * * @return mixed The processed item. */ private static function human_readable_schema( $item ) { // If the item is an associative array with 'type' as a key, return its value directly if ( is_array( $item ) && isset( $item['type'] ) && count( $item ) === 1 ) { return $item['type']; } // If the item is an associative array with 'type' and 'value', process the value if ( isset( $item['type'], $item['value'] ) && is_array( $item ) ) { return self::human_readable_schema( $item['value'] ); } // If the item is any other kind of array, process each sub-item if ( is_array( $item ) ) { $result = array(); foreach ( $item as $key => $value ) { $result[ $key ] = self::human_readable_schema( $value ); } return $result; } return $item; } }