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

Get detailed changes made to the layout for user feedback.


Description

Compares current layout with new layout to identify what was added/removed/moved.


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/footer/class-astra-update-footer-builder.php

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

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

			foreach ( $columns as $column => $components ) {
				if ( ! is_array( $components ) ) {
					continue;
				}

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

				$column_label = $this->get_column_label( $section, $column );

				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 ),
						$column_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 ),
								$column_label,
								$device,
								implode( ', ', $existing_names )
							);
						} else {
							$changes[] = sprintf(
								'Added %s to %s (%s)',
								implode( ', ', $component_names ),
								$column_label,
								$device
							);
						}
					}
				}
			}
		}

		return $changes;
	}


User Contributed Notes

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