# elementor/4.3.0-beta3/modules/mcp/abilities/utils/v3-controls-metadata.php

Elementor Website Builder – more than just a page builder, version 4.3.0-beta3. 74 lines.

- Page: https://pluginprobe.com/plugins/elementor/4.3.0-beta3/code/modules/mcp/abilities/utils/v3-controls-metadata.php
- Raw: https://pluginprobe.com/plugins/elementor/4.3.0-beta3/raw/modules/mcp/abilities/utils/v3-controls-metadata.php
- Modified: 2026-09-01T11:47:36+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/elementor/4.3.0-beta3/code/modules/mcp/abilities/utils/v3-controls-metadata.php#L10-L20`.

```php
<?php

namespace Elementor\Modules\Mcp\Abilities\Utils;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

class V3_Controls_Metadata {

	const LAYOUT_CONTROL_TYPES = [ 'section', 'tab', 'tabs' ];

	/**
	 * @param mixed         $controls     Widget controls stack.
	 * @param string[]|null $allowed_keys When provided, only these control keys are emitted.
	 */
	public static function extract( $controls, ?array $allowed_keys = null ): array {
		if ( ! is_array( $controls ) || empty( $controls ) ) {
			return [];
		}

		$allowed_lookup = null === $allowed_keys
			? null
			: array_fill_keys( $allowed_keys, true );

		$result = [];

		foreach ( $controls as $control_key => $control ) {
			if ( ! is_array( $control ) ) {
				continue;
			}

			if ( null !== $allowed_lookup && ! isset( $allowed_lookup[ $control_key ] ) ) {
				continue;
			}

			$control_type = is_string( $control['type'] ?? null ) ? $control['type'] : null;

			if ( $control_type && in_array( $control_type, self::LAYOUT_CONTROL_TYPES, true ) ) {
				continue;
			}

			$result[ $control_key ] = self::build_entry( $control, $control_type );
		}

		return $result;
	}

	private static function build_entry( array $control, ?string $control_type ): array {
		$entry = [];

		if ( array_key_exists( 'default', $control ) ) {
			$entry['default'] = $control['default'];
		}

		if ( $control_type ) {
			$entry['type'] = $control_type;
		}

		if ( isset( $control['options'] ) ) {
			$options = $control['options'];
			$entry['options'] = ( is_array( $options ) && self::is_associative_array( $options ) )
				? array_keys( $options )
				: $options;
		}

		return $entry;
	}

	private static function is_associative_array( array $arr ): bool {
		return array_keys( $arr ) !== range( 0, count( $arr ) - 1 );
	}
}

```
