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::sanitize_header_layout( array $layout, string $type = 'desktop' )

Sanitize header layout data.


Description


Parameters

$layout

(array) (Required) Layout array.

$type

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

Default value: 'desktop'


Return

(array) Sanitized layout.


Source

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

	private function sanitize_header_layout( $layout, $type = 'desktop' ) {
		$sanitized = array();
		$sections  = array( 'popup', 'above', 'primary', 'below' );

		$desktop_zones = array(
			'popup'   => array( 'popup_content' ),
			'above'   => array( 'above_left', 'above_left_center', 'above_center', 'above_right_center', 'above_right' ),
			'primary' => array( 'primary_left', 'primary_left_center', 'primary_center', 'primary_right_center', 'primary_right' ),
			'below'   => array( 'below_left', 'below_left_center', 'below_center', 'below_right_center', 'below_right' ),
		);

		$mobile_zones = array(
			'popup'   => array( 'popup_content' ),
			'above'   => array( 'above_left', 'above_center', 'above_right' ),
			'primary' => array( 'primary_left', 'primary_center', 'primary_right' ),
			'below'   => array( 'below_left', 'below_center', 'below_right' ),
		);

		$zones = 'desktop' === $type ? $desktop_zones : $mobile_zones;

		foreach ( $sections as $section ) {
			if ( isset( $layout[ $section ] ) && is_array( $layout[ $section ] ) ) {
				$section_zones = array();
				foreach ( $zones[ $section ] as $zone ) {
					if ( isset( $layout[ $section ][ $zone ] ) && is_array( $layout[ $section ][ $zone ] ) ) {
						$normalized = array_map( array( $this, 'normalize_component_id' ), $layout[ $section ][ $zone ] );

						$section_zones[ $zone ] = $normalized;
					}
				}

				if ( ! empty( $section_zones ) ) {
					$sanitized[ $section ] = $section_zones;
				}
			}
		}

		return $sanitized;
	}


User Contributed Notes

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