astra_above_header_builder_migration( array $theme_options, array $used_elements, array $widget_options )

Header Footer builder – Migration of Above Header.


Description


Parameters

$theme_options

(array) (Required) Theme options.

$used_elements

(array) (Required) Used Elements array.

$widget_options

(array) (Required) Widget options.


Return

(array)


Source

File: inc/theme-update/astra-builder-migration-updater.php

function astra_above_header_builder_migration( $theme_options, $used_elements, $widget_options ) {
	/**
	 * Above Header.
	 */

	$above_header_layout      = ( isset( $theme_options['above-header-layout'] ) ) ? $theme_options['above-header-layout'] : '';
	$above_header_on_mobile   = ( isset( $theme_options['above-header-on-mobile'] ) ) ? $theme_options['above-header-on-mobile'] : '';
	$above_header_merge_menu  = ( isset( $theme_options['above-header-merge-menu'] ) ) ? $theme_options['above-header-merge-menu'] : '';
	$above_header_swap_mobile = ( isset( $theme_options['above-header-swap-mobile'] ) ) ? $theme_options['above-header-swap-mobile'] : '';

	if ( isset( $theme_options['above-header-height'] ) ) {
		$theme_options['hba-header-height'] = array(
			'desktop' => $theme_options['above-header-height'],
			'tablet'  => '',
			'mobile'  => '',
		);
	}
	if ( isset( $theme_options['above-header-divider'] ) ) {
		$theme_options['hba-header-separator'] = $theme_options['above-header-divider'];
	}
	if ( isset( $theme_options['above-header-divider-color'] ) ) {
		$theme_options['hba-header-bottom-border-color'] = $theme_options['above-header-divider-color'];
	}
	if ( isset( $theme_options['above-header-bg-obj-responsive'] ) ) {
		$theme_options['hba-header-bg-obj-responsive'] = $theme_options['above-header-bg-obj-responsive'];
	}
	if ( isset( $theme_options['above-header-spacing'] ) ) {
		$theme_options['section-above-header-builder-padding'] = $theme_options['above-header-spacing'];
	}
	// Above Header Section 1.
	$above_header_section_1          = ( isset( $theme_options['above-header-section-1'] ) ) ? $theme_options['above-header-section-1'] : '';
	$new_above_header_section_1_item = '';

	switch ( $above_header_section_1 ) {
		case 'menu':
			$new_above_header_section_1_item = 'menu-3';
			break;

		case 'search':
			if ( ! in_array( 'search', $used_elements ) ) {
				$new_above_header_section_1_item = 'search';
				if ( isset( $theme_options['above-header-section-1-search-box-type'] ) ) {
					$theme_options['header-search-box-type'] = $theme_options['above-header-section-1-search-box-type'];
				}
			}
			break;

		case 'text-html':
			if ( ! in_array( 'html-3', $used_elements ) ) {
				$new_above_header_section_1_item = 'html-3';
				if ( isset( $theme_options['above-header-section-1-html'] ) ) {
					$theme_options['header-html-3'] = $theme_options['above-header-section-1-html'];
				}
			}

			break;

		case 'widget':
			if ( ! in_array( 'widget-3', $used_elements ) ) {
				$new_above_header_section_1_item = 'widget-3';
				if ( isset( $widget_options['above-header-widget-1'] ) ) {
					$widget_options['header-widget-3'] = $widget_options['above-header-widget-1'];
				}
			}
			break;

		case 'woocommerce':
			if ( ! in_array( 'woo-cart', $used_elements ) ) {
				$new_above_header_section_1_item = 'woo-cart';
			}
			break;

		case 'edd':
			if ( ! in_array( 'edd-cart', $used_elements ) ) {
				$new_above_header_section_1_item = 'edd-cart';
			}
			break;
	}

	// Above Header Section 2.
	$above_header_section_2          = ( isset( $theme_options['above-header-section-2'] ) ) ? $theme_options['above-header-section-2'] : '';
	$new_above_header_section_2_item = '';
	switch ( $above_header_section_2 ) {
		case 'menu':
			$new_above_header_section_2_item = 'menu-3';
			break;

		case 'search':
			if ( ! in_array( 'search', $used_elements ) ) {
				$new_above_header_section_2_item = 'search';
				if ( isset( $theme_options['above-header-section-2-search-box-type'] ) ) {
					$theme_options['header-search-box-type'] = $theme_options['above-header-section-2-search-box-type'];
				}
			}
			break;

		case 'text-html':
			if ( ! in_array( 'html-3', $used_elements ) ) {
				$new_above_header_section_2_item = 'html-3';
				if ( isset( $theme_options['above-header-section-2-html'] ) ) {
					$theme_options['header-html-3'] = $theme_options['above-header-section-2-html'];
				}
			}

			break;

		case 'widget':
			if ( ! in_array( 'widget-3', $used_elements ) ) {
				$new_above_header_section_2_item = 'widget-3';
				if ( isset( $widget_options['above-header-widget-2'] ) ) {
					$widget_options['header-widget-3'] = $widget_options['above-header-widget-2'];
				}
			}
			break;

		case 'woocommerce':
			if ( ! in_array( 'woo-cart', $used_elements ) ) {
				$new_above_header_section_2_item = 'woo-cart';
			}
			break;

		case 'edd':
			if ( ! in_array( 'edd-cart', $used_elements ) ) {
				$new_above_header_section_2_item = 'edd-cart';
			}
			break;
	}

	if ( 'menu' === $above_header_section_1 || 'menu' === $above_header_section_2 ) {
		$theme_options['header-menu3-menu-stack-on-mobile'] = false;
		/**
		 * Menu - 3
		 */
		if ( isset( $theme_options['above-header-submenu-container-animation'] ) ) {
			$theme_options['header-menu3-submenu-container-animation'] = $theme_options['above-header-submenu-container-animation'];
		}
		if ( isset( $theme_options['above-header-submenu-border'] ) ) {
			$theme_options['header-menu3-submenu-border'] = $theme_options['above-header-submenu-border'];
		}
		if ( isset( $theme_options['above-header-submenu-b-color'] ) ) {
			$theme_options['header-menu3-submenu-b-color'] = $theme_options['above-header-submenu-b-color'];
		}
		if ( isset( $theme_options['above-header-submenu-item-border'] ) ) {
			$theme_options['header-menu3-submenu-item-border'] = $theme_options['above-header-submenu-item-border'];
		}
		if ( isset( $theme_options['above-header-submenu-item-b-color'] ) ) {
			$theme_options['header-menu3-submenu-item-b-color'] = $theme_options['above-header-submenu-item-b-color'];
		}

		if ( isset( $theme_options['above-header-menu-text-color-responsive'] ) ) {
			$theme_options['header-menu3-color-responsive'] = $theme_options['above-header-menu-text-color-responsive'];
		}
		if ( isset( $theme_options['above-header-menu-bg-obj-responsive'] ) ) {
			$theme_options['header-menu3-bg-obj-responsive'] = $theme_options['above-header-menu-bg-obj-responsive'];
		}

		if ( isset( $theme_options['above-header-menu-text-hover-color-responsive'] ) ) {
			$theme_options['header-menu3-h-color-responsive'] = $theme_options['above-header-menu-text-hover-color-responsive'];
		}
		if ( isset( $theme_options['above-header-menu-bg-hover-color-responsive'] ) ) {
			$theme_options['header-menu3-h-bg-color-responsive'] = $theme_options['above-header-menu-bg-hover-color-responsive'];
		}

		if ( isset( $theme_options['above-header-current-menu-text-color-responsive'] ) ) {
			$theme_options['header-menu3-a-color-responsive'] = $theme_options['above-header-current-menu-text-color-responsive'];
		}
		if ( isset( $theme_options['above-header-current-menu-bg-color-responsive'] ) ) {
			$theme_options['header-menu3-a-bg-color-responsive'] = $theme_options['above-header-current-menu-bg-color-responsive'];
		}

		if ( isset( $theme_options['above-header-font-size'] ) ) {
			$theme_options['header-menu3-font-size'] = $theme_options['above-header-font-size'];
		}
		if ( isset( $theme_options['above-header-font-weight'] ) ) {
			$theme_options['header-menu3-font-weight'] = $theme_options['above-header-font-weight'];
		}
		if ( isset( $theme_options['above-header-line-height'] ) ) {
			$theme_options['header-menu3-line-height'] = $theme_options['above-header-line-height'];
		}
		if ( isset( $theme_options['above-header-font-family'] ) ) {
			$theme_options['header-menu3-font-family'] = $theme_options['above-header-font-family'];
		}
		if ( isset( $theme_options['above-header-text-transform'] ) ) {
			$theme_options['header-menu3-text-transform'] = $theme_options['above-header-text-transform'];
		}

		if ( isset( $theme_options['above-header-menu-spacing'] ) ) {
			$theme_options['header-menu3-menu-spacing'] = $theme_options['above-header-menu-spacing'];
		}

		// Menu 3 - Submenu.
		if ( isset( $theme_options['above-header-submenu-text-color-responsive'] ) ) {
			$theme_options['header-menu3-submenu-color-responsive'] = $theme_options['above-header-submenu-text-color-responsive'];
		}
		if ( isset( $theme_options['above-header-submenu-bg-color-responsive'] ) ) {
			$theme_options['header-menu3-submenu-bg-color-responsive'] = $theme_options['above-header-submenu-bg-color-responsive'];
		}

		if ( isset( $theme_options['above-header-submenu-hover-color-responsive'] ) ) {
			$theme_options['header-menu3-submenu-h-color-responsive'] = $theme_options['above-header-submenu-hover-color-responsive'];
		}
		if ( isset( $theme_options['above-header-submenu-bg-hover-color-responsive'] ) ) {
			$theme_options['header-menu3-submenu-h-bg-color-responsive'] = $theme_options['above-header-submenu-bg-hover-color-responsive'];
		}

		if ( isset( $theme_options['above-header-submenu-active-color-responsive'] ) ) {
			$theme_options['header-menu3-submenu-a-color-responsive'] = $theme_options['above-header-submenu-active-color-responsive'];
		}
		if ( isset( $theme_options['above-header-submenu-active-bg-color-responsive'] ) ) {
			$theme_options['header-menu3-submenu-a-bg-color-responsive'] = $theme_options['above-header-submenu-active-bg-color-responsive'];
		}

		if ( isset( $theme_options['font-size-above-header-dropdown-menu'] ) ) {
			$theme_options['header-font-size-menu3-sub-menu'] = $theme_options['font-size-above-header-dropdown-menu'];
		}
		if ( isset( $theme_options['font-weight-above-header-dropdown-menu'] ) ) {
			$theme_options['header-font-weight-menu3-sub-menu'] = $theme_options['font-weight-above-header-dropdown-menu'];
		}
		if ( isset( $theme_options['line-height-above-header-dropdown-menu'] ) ) {
			$theme_options['header-line-height-menu3-sub-menu'] = $theme_options['line-height-above-header-dropdown-menu'];
		}
		if ( isset( $theme_options['font-family-above-header-dropdown-menu'] ) ) {
			$theme_options['header-font-family-menu3-sub-menu'] = $theme_options['font-family-above-header-dropdown-menu'];
		}
		if ( isset( $theme_options['text-transform-above-header-dropdown-menu'] ) ) {
			$theme_options['header-text-transform-menu3-sub-menu'] = $theme_options['text-transform-above-header-dropdown-menu'];
		}

		if ( isset( $theme_options['above-header-submenu-spacing'] ) ) {
			$theme_options['header-menu3-submenu-spacing'] = $theme_options['above-header-submenu-spacing'];
		}
	}

	if ( 'search' === $above_header_section_1 || 'search' === $above_header_section_2 ) {
		if ( isset( $theme_options['above-header-text-color-responsive'] ) ) {
			$theme_options['header-search-icon-color'] = $theme_options['above-header-text-color-responsive'];
		}
	}

	if ( 'text-html' === $above_header_section_1 || 'text-html' === $above_header_section_2 ) {
		if ( isset( $theme_options['above-header-text-color-responsive'] ) ) {
			$theme_options['header-html-3color'] = $theme_options['above-header-text-color-responsive'];
		}
		if ( isset( $theme_options['above-header-link-color-responsive'] ) ) {
			$theme_options['header-html-3link-color'] = $theme_options['above-header-link-color-responsive'];
		}
		if ( isset( $theme_options['above-header-link-hover-color-responsive'] ) ) {
			$theme_options['header-html-3link-h-color'] = $theme_options['above-header-link-hover-color-responsive'];
		}
		if ( isset( $theme_options['font-size-above-header-content'] ) ) {
			$theme_options['font-size-section-hb-html-3'] = $theme_options['font-size-above-header-content'];
		}
		if ( isset( $theme_options['font-weight-above-header-content'] ) ) {
			$theme_options['font-weight-section-hb-html-3'] = $theme_options['font-weight-above-header-content'];
		}
		if ( isset( $theme_options['line-height-above-header-content'] ) ) {
			$theme_options['line-height-section-hb-html-3'] = $theme_options['line-height-above-header-content'];
		}
		if ( isset( $theme_options['font-family-above-header-content'] ) ) {
			$theme_options['font-family-section-hb-html-3'] = $theme_options['font-family-above-header-content'];
		}
		if ( isset( $theme_options['text-transform-above-header-content'] ) ) {
			$theme_options['text-transform-section-hb-html-3'] = $theme_options['text-transform-above-header-content'];
		}
	}

	if ( 'widget' === $above_header_section_1 || 'widget' === $above_header_section_2 ) {
		if ( isset( $theme_options['above-header-text-color-responsive'] ) ) {
			$theme_options['header-widget-3-color']       = $theme_options['above-header-text-color-responsive'];
			$theme_options['header-widget-3-title-color'] = $theme_options['above-header-text-color-responsive'];
		}
		if ( isset( $theme_options['above-header-link-color-responsive'] ) ) {
			$theme_options['header-widget-3-link-color'] = $theme_options['above-header-link-color-responsive'];
		}
		if ( isset( $theme_options['above-header-link-hover-color-responsive'] ) ) {
			$theme_options['header-widget-3-link-h-color'] = $theme_options['above-header-link-hover-color-responsive'];
		}
		if ( isset( $theme_options['font-size-above-header-content'] ) ) {
			$theme_options['header-widget-3-content-font-size'] = $theme_options['font-size-above-header-content'];
		}
		if ( isset( $theme_options['font-weight-above-header-content'] ) ) {
			$theme_options['header-widget-3-content-font-weight'] = $theme_options['font-weight-above-header-content'];
		}
		if ( isset( $theme_options['line-height-above-header-content'] ) ) {
			$theme_options['header-widget-3-content-line-height'] = $theme_options['line-height-above-header-content'];
		}
		if ( isset( $theme_options['font-family-above-header-content'] ) ) {
			$theme_options['header-widget-3-content-font-family'] = $theme_options['font-family-above-header-content'];
		}
		if ( isset( $theme_options['text-transform-above-header-content'] ) ) {
			$theme_options['header-widget-3-content-text-transform'] = $theme_options['text-transform-above-header-content'];
		}
	}

	switch ( $above_header_layout ) {

		case 'above-header-layout-1':
			$theme_options['header-desktop-items']['above'] = array(
				'above_left'         => ( '' !== $new_above_header_section_1_item ) ? array( $new_above_header_section_1_item ) : array(),
				'above_left_center'  => array(),
				'above_center'       => array(),
				'above_right_center' => array(),
				'above_right'        => ( '' !== $new_above_header_section_2_item ) ? array( $new_above_header_section_2_item ) : array(),
			);
			break;

		case 'above-header-layout-2':
			$theme_options['header-desktop-items']['above'] = array(
				'above_left'         => array(),
				'above_left_center'  => array(),
				'above_center'       => ( '' !== $new_above_header_section_1_item ) ? array( $new_above_header_section_1_item ) : array(),
				'above_right_center' => array(),
				'above_right'        => array(),
			);
			break;
	}

	if ( $above_header_on_mobile ) {

		if ( $above_header_swap_mobile && ( 'menu' === $above_header_section_1 || 'menu' === $above_header_section_2 ) ) {
			$temp                            = $new_above_header_section_1_item;
			$new_above_header_section_1_item = $new_above_header_section_2_item;
			$new_above_header_section_2_item = $temp;
		}

		if ( $above_header_merge_menu && ( 'menu' === $above_header_section_1 || 'menu' === $above_header_section_2 ) ) {
			if ( '' !== $new_above_header_section_1_item ) {
				$theme_options['header-mobile-items']['popup']['popup_content'][] = $new_above_header_section_1_item;
			}
			if ( '' !== $new_above_header_section_2_item ) {
				$theme_options['header-mobile-items']['popup']['popup_content'][] = $new_above_header_section_2_item;
			}
			$theme_options['header-menu3-menu-stack-on-mobile'] = true;
			$theme_options['header-mobile-items']['above']      = array(
				'above_left'   => array(),
				'above_center' => array(),
				'above_right'  => array(),
			);
		} else {
			switch ( $above_header_layout ) {

				case 'above-header-layout-1':
					$theme_options['header-mobile-items']['above'] = array(
						'above_left'   => ( '' !== $new_above_header_section_1_item ) ? array( $new_above_header_section_1_item ) : array(),
						'above_center' => array(),
						'above_right'  => ( '' !== $new_above_header_section_2_item ) ? array( $new_above_header_section_2_item ) : array(),
					);
					break;

				case 'above-header-layout-2':
					$theme_options['header-mobile-items']['above'] = array(
						'above_left'   => array(),
						'above_center' => ( '' !== $new_above_header_section_1_item ) ? array( $new_above_header_section_1_item ) : array(),
						'above_right'  => array(),
					);
					break;
			}
		}
	}

	return array(
		'theme_options'  => $theme_options,
		'used_elements'  => $used_elements,
		'widget_options' => $widget_options,
	);

}

Changelog

Changelog
Version Description
3.0.0 Introduced.


User Contributed Notes

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