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_Update_Header_Builder::get_layout_changes( array $current_layout, array $new_layout, string $device )

Get detailed changes made to the layout for user feedback.


Description


Parameters

$current_layout

(array) (Required) Current layout structure.

$new_layout

(array) (Required) New layout being applied.

$device

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


Return

(array) Array of change descriptions.


Source

File: inc/abilities/customizer/header/class-astra-update-header-builder.php

	private function get_layout_changes( $current_layout, $new_layout, $device ) {
		$changes = array();

		foreach ( $new_layout as $section => $zones ) {
			if ( ! is_array( $zones ) ) {
				continue;
			}

			foreach ( $zones as $zone => $components ) {
				if ( ! is_array( $components ) ) {
					continue;
				}

				$existing = isset( $current_layout[ $section ][ $zone ] ) && is_array( $current_layout[ $section ][ $zone ] )
					? $current_layout[ $section ][ $zone ]
					: array();

				$zone_label = $this->get_zone_label( $section, $zone );

				if ( empty( $components ) && ! empty( $existing ) ) {
					$existing_names = array_map( array( $this, 'get_component_name' ), $existing );
					$changes[]      = sprintf(
						'Removed %s from %s (%s)',
						implode( ', ', $existing_names ),
						$zone_label,
						$device
					);
					continue;
				}

				if ( ! empty( $components ) ) {
					$new_components = array_diff( $components, $existing );

					if ( ! empty( $new_components ) ) {
						$component_names = array_map( array( $this, 'get_component_name' ), $new_components );

						if ( ! empty( $existing ) ) {
							$existing_names = array_map( array( $this, 'get_component_name' ), $existing );
							$changes[]      = sprintf(
								'Added %s to %s (%s) alongside existing %s',
								implode( ', ', $component_names ),
								$zone_label,
								$device,
								implode( ', ', $existing_names )
							);
						} else {
							$changes[] = sprintf(
								'Added %s to %s (%s)',
								implode( ', ', $component_names ),
								$zone_label,
								$device
							);
						}
					}
				}
			}
		}

		return $changes;
	}


User Contributed Notes

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