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::normalize_component_id( string $component_id )

Normalize component ID to match Astra’s expected format.


Description

Maps common variations and incorrect IDs to the correct component IDs.


Parameters

$component_id

(string) (Required) Component ID to normalize.


Return

(string) Normalized component ID.


Source

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

	private function normalize_component_id( $component_id ) {
		$component_id = sanitize_text_field( $component_id );
		$component_id = strtolower( trim( $component_id ) );

		$id_mapping = array(
			// Menu variations.
			'menu'              => 'menu-1',
			'menu_primary'      => 'menu-1',
			'primary_menu'      => 'menu-1',
			'primary-menu'      => 'menu-1',
			'menu_1'            => 'menu-1',
			'menu_secondary'    => 'menu-2',
			'secondary_menu'    => 'menu-2',
			'secondary-menu'    => 'menu-2',
			'menu_2'            => 'menu-2',
			// Social icons variations.
			'social'            => 'social-icons-1',
			'social_icons'      => 'social-icons-1',
			'social-icons'      => 'social-icons-1',
			'social_icons_1'    => 'social-icons-1',
			'social_1'          => 'social-icons-1',
			'social-1'          => 'social-icons-1',
			'social_icons_2'    => 'social-icons-2',
			'social_2'          => 'social-icons-2',
			'social-2'          => 'social-icons-2',
			// Button variations.
			'button'            => 'button-1',
			'btn'               => 'button-1',
			'button_1'          => 'button-1',
			'button_2'          => 'button-2',
			'button_3'          => 'button-3',
			'btn-1'             => 'button-1',
			'btn-2'             => 'button-2',
			'btn-3'             => 'button-3',
			// HTML variations.
			'html'              => 'html-1',
			'html_1'            => 'html-1',
			'html_2'            => 'html-2',
			'html_3'            => 'html-3',
			// Widget variations.
			'widget'            => 'widget-1',
			'widget_1'          => 'widget-1',
			'widget_2'          => 'widget-2',
			'widget_3'          => 'widget-3',
			// Mobile variations.
			'mobile_menu'       => 'mobile-menu',
			'mobile_trigger'    => 'mobile-trigger',
			'hamburger'         => 'mobile-trigger',
			'menu-toggle'       => 'mobile-trigger',
			// Logo variations.
			'site_logo'         => 'logo',
			'site-logo'         => 'logo',
			'site_title'        => 'logo',
			'site-title'        => 'logo',
			// Search variations.
			'search_bar'        => 'search',
			'search-bar'        => 'search',
			'search_box'        => 'search',
			'search-box'        => 'search',
			// WooCommerce variations.
			'cart'              => 'woo-cart',
			'woo_cart'          => 'woo-cart',
			'woocommerce_cart'  => 'woo-cart',
			'woocommerce-cart'  => 'woo-cart',
			// EDD variations.
			'edd_cart'          => 'edd-cart',
			// Account variations.
			'user_account'      => 'account',
			'user-account'      => 'account',
			'login'             => 'account',
			// Other variations.
			'language_switcher' => 'language-switcher',
		);

		if ( isset( $id_mapping[ $component_id ] ) ) {
			return $id_mapping[ $component_id ];
		}

		return $component_id;
	}

User Contributed Notes

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