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

Header Footer builder – Migration of Below 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_below_header_builder_migration( $theme_options, $used_elements, $widget_options ) {
	/**
	 * Below Header
	 */

	$below_header_layout      = ( isset( $theme_options['below-header-layout'] ) ) ? $theme_options['below-header-layout'] : '';
	$below_header_on_mobile   = ( isset( $theme_options['below-header-on-mobile'] ) ) ? $theme_options['below-header-on-mobile'] : '';
	$below_header_merge_menu  = ( isset( $theme_options['below-header-merge-menu'] ) ) ? $theme_options['below-header-merge-menu'] : '';
	$below_header_swap_mobile = ( isset( $theme_options['below-header-swap-mobile'] ) ) ? $theme_options['below-header-swap-mobile'] : '';

	if ( isset( $theme_options['below-header-height'] ) ) {
		$theme_options['hbb-header-height'] = array(
			'desktop' => $theme_options['below-header-height'],
			'tablet'  => '',
			'mobile'  => '',
		);
	}

	if ( isset( $theme_options['below-header-divider'] ) ) {
		$theme_options['hbb-header-separator'] = $theme_options['below-header-divider'];
	}
	if ( isset( $theme_options['below-header-divider-color'] ) ) {
		$theme_options['hbb-header-bottom-border-color'] = $theme_options['below-header-divider-color'];
	}
	if ( isset( $theme_options['below-header-bg-obj-responsive'] ) ) {
		$theme_options['hbb-header-bg-obj-responsive'] = $theme_options['below-header-bg-obj-responsive'];
	}
	if ( isset( $theme_options['below-header-spacing'] ) ) {
		$theme_options['section-below-header-builder-padding'] = $theme_options['below-header-spacing'];
	}
	// Below Header Section 1.
	$below_header_section_1          = ( isset( $theme_options['below-header-section-1'] ) ) ? $theme_options['below-header-section-1'] : '';
	$new_below_header_section_1_item = '';
	switch ( $below_header_section_1 ) {
		case 'menu':
			$new_below_header_section_1_item = 'menu-2';
			break;

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

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

			break;

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

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

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

	// Below Header Section 2.
	$below_header_section_2          = ( isset( $theme_options['below-header-section-2'] ) ) ? $theme_options['below-header-section-2'] : '';
	$new_below_header_section_2_item = '';
	switch ( $below_header_section_2 ) {
		case 'menu':
			$new_below_header_section_2_item = 'menu-2';
			break;

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

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

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

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

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

	if ( 'menu' === $below_header_section_1 || 'menu' === $below_header_section_2 ) {
		$theme_options['header-menu2-menu-stack-on-mobile'] = false;
		/**
		 * Menu - 2
		 */
		if ( isset( $theme_options['below-header-submenu-container-animation'] ) ) {
			$theme_options['header-menu2-submenu-container-animation'] = $theme_options['below-header-submenu-container-animation'];
		}
		if ( isset( $theme_options['below-header-submenu-border'] ) ) {
			$theme_options['header-menu2-submenu-border'] = $theme_options['below-header-submenu-border'];
		}
		if ( isset( $theme_options['below-header-submenu-b-color'] ) ) {
			$theme_options['header-menu2-submenu-b-color'] = $theme_options['below-header-submenu-b-color'];
		}
		if ( isset( $theme_options['below-header-submenu-item-border'] ) ) {
			$theme_options['header-menu2-submenu-item-border'] = $theme_options['below-header-submenu-item-border'];
		}
		if ( isset( $theme_options['below-header-submenu-item-b-color'] ) ) {
			$theme_options['header-menu2-submenu-item-b-color'] = $theme_options['below-header-submenu-item-b-color'];
		}

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

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

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

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

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

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

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

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

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

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

	if ( 'search' === $below_header_section_1 || 'search' === $below_header_section_2 ) {
		if ( isset( $theme_options['below-header-text-color-responsive'] ) ) {
			$theme_options['header-search-icon-color'] = $theme_options['below-header-text-color-responsive'];
		}
	}

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

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

	switch ( $below_header_layout ) {

		case 'below-header-layout-1':
			$theme_options['header-desktop-items']['below'] = array(
				'below_left'         => ( '' !== $new_below_header_section_1_item ) ? array( $new_below_header_section_1_item ) : array(),
				'below_left_center'  => array(),
				'below_center'       => array(),
				'below_right_center' => array(),
				'below_right'        => ( '' !== $new_below_header_section_2_item ) ? array( $new_below_header_section_2_item ) : array(),
			);
			break;

		case 'below-header-layout-2':
			$theme_options['header-desktop-items']['below'] = array(
				'below_left'         => array(),
				'below_left_center'  => array(),
				'below_center'       => ( '' !== $new_below_header_section_1_item ) ? array( $new_below_header_section_1_item ) : array(),
				'below_right_center' => array(),
				'below_right'        => array(),
			);
			break;
	}

	if ( $below_header_on_mobile ) {

		if ( $below_header_swap_mobile && ( 'menu' === $below_header_section_1 || 'menu' === $below_header_section_2 ) ) {
			$temp                            = $new_below_header_section_1_item;
			$new_below_header_section_1_item = $new_below_header_section_2_item;
			$new_below_header_section_2_item = $temp;
		}

		if ( $below_header_merge_menu && ( 'menu' === $below_header_section_1 || 'menu' === $below_header_section_2 ) ) {
			if ( '' !== $new_below_header_section_1_item ) {
				$theme_options['header-mobile-items']['popup']['popup_content'][] = $new_below_header_section_1_item;
			}
			if ( '' !== $new_below_header_section_2_item ) {
				$theme_options['header-mobile-items']['popup']['popup_content'][] = $new_below_header_section_2_item;
			}
			$theme_options['header-menu2-menu-stack-on-mobile'] = true;
			$theme_options['header-mobile-items']['below']      = array(
				'below_left'   => array(),
				'below_center' => array(),
				'below_right'  => array(),
			);
		} else {
			switch ( $below_header_layout ) {

				case 'below-header-layout-1':
					$theme_options['header-mobile-items']['below'] = array(
						'below_left'   => ( '' !== $new_below_header_section_1_item ) ? array( $new_below_header_section_1_item ) : array(),
						'below_center' => array(),
						'below_right'  => ( '' !== $new_below_header_section_2_item ) ? array( $new_below_header_section_2_item ) : array(),
					);
					break;

				case 'below-header-layout-2':
					$theme_options['header-mobile-items']['below'] = array(
						'below_left'   => array(),
						'below_center' => ( '' !== $new_below_header_section_1_item ) ? array( $new_below_header_section_1_item ) : array(),
						'below_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.