This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Astra_Migrate_Header_Components::migrate_layout( array $layout, string $type )

Migrate a header layout by normalizing component IDs.


Description


Parameters

$layout

(array) (Required) Layout array.

$type

(string) (Required) Layout type (desktop or mobile).


Return

(array) Migration result with changed status, count, changes, and migrated layout.


Source

File: inc/abilities/customizer/header/class-astra-migrate-header-components.php

	private function migrate_layout( $layout, $type ) {
		$sections = array( 'popup', 'above', 'primary', 'below' );
		$changes  = array();
		$count    = 0;
		$changed  = false;

		foreach ( $sections as $section ) {
			if ( ! isset( $layout[ $section ] ) || ! is_array( $layout[ $section ] ) ) {
				continue;
			}

			foreach ( $layout[ $section ] as $zone => $components ) {
				if ( ! is_array( $components ) ) {
					continue;
				}

				$normalized_components = array();
				foreach ( $components as $component_id ) {
					$normalized_id = $this->normalize_component_id( $component_id );

					if ( $normalized_id !== $component_id ) {
						$changes[] = array(
							'section' => $section,
							'zone'    => $zone,
							'old_id'  => $component_id,
							'new_id'  => $normalized_id,
						);
						++$count;
						$changed = true;
					}

					$normalized_components[] = $normalized_id;
				}

				$layout[ $section ][ $zone ] = $normalized_components;
			}
		}

		return array(
			'changed' => $changed,
			'count'   => $count,
			'changes' => $changes,
			'layout'  => $layout,
		);
	}


User Contributed Notes

You must log in before being able to contribute a note or feedback.