# elementor/4.3.0-beta3/modules/components/utils/strip-component-instances.php

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

- Page: https://pluginprobe.com/plugins/elementor/4.3.0-beta3/code/modules/components/utils/strip-component-instances.php
- Raw: https://pluginprobe.com/plugins/elementor/4.3.0-beta3/raw/modules/components/utils/strip-component-instances.php
- Modified: 2026-09-08T11:16:58+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/components/utils/strip-component-instances.php#L10-L20`.

```php
<?php

namespace Elementor\Modules\Components\Utils;

use Elementor\Modules\Components\PropTypes\Component_Instance_Prop_Type;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Removes every `e-component` widget from an elements tree.
 *
 * Used at import time when components round-trip is disabled, to clean up any dangling
 * `e-component` widgets that survived from a zip exported before the flag or by an
 * external site. Dangling instances would point at nonexistent component posts and
 * either render empty or throw in the editor panel.
 */
class Strip_Component_Instances {
	public static function apply( array $elements ): array {
		$result = [];

		foreach ( $elements as $element ) {
			if ( ! is_array( $element ) ) {
				$result[] = $element;
				continue;
			}

			if ( Component_Instance_Prop_Type::is_instance_element( $element ) ) {
				continue;
			}

			if ( ! empty( $element['elements'] ) && is_array( $element['elements'] ) ) {
				$element['elements'] = self::apply( $element['elements'] );
			}

			$result[] = $element;
		}

		return $result;
	}
}

```
