Astra_Addon_Builder_UI_Controller::render_language_switcher_markup( string $index = 'header-language-switcher', string $builder_type = 'header' )
Prepare language switcher Markup.
Description
Parameters
- $index
-
(string) (Optional) Key of the language switcher Control.
Default value: 'header-language-switcher'
- $builder_type
-
(string) (Optional) builder type.
Default value: 'header'
Source
File: classes/builder/type/base/controllers/class-astra-addon-builder-ui-controller.php
public static function render_language_switcher_markup( $index = 'header-language-switcher', $builder_type = 'header' ) { $lang_type = astra_get_option( $index . '-type' ); $layout = astra_get_option( $index . '-layout' ); $show_flag = astra_get_option( $index . '-show-flag' ); $show_label = astra_get_option( $index . '-show-name' ); ?> <div class="ast-builder-language-switcher-wrapper ast-builder-language-switcher-layout-<?php echo esc_attr( $layout ); ?>"> <?php if ( is_customize_preview() ) { self::render_customizer_edit_button(); } ?> <div class="ast-builder-language-switcher-element"> <?php if ( 'wpml' === $lang_type ) { $show_tname = astra_get_option( $index . '-show-tname' ); $show_code = astra_get_option( $index . '-show-code' ); $languages = apply_filters( 'wpml_active_languages', null, array( 'skip_missing' => 0, ) ); if ( ! empty( $languages ) ) { ?> <nav class="ast-builder-language-switcher"><ul class="ast-builder-language-switcher-menu"> <?php foreach ( $languages as $language ) { ?> <li class="ast-builder-language-switcher-menu-item-<?php echo esc_attr( $builder_type ); ?>"> <?php if ( isset( $language['active'] ) ) { ?> <a href="<?php echo esc_url( $language['url'] ); ?>" class="ast-builder-language-switcher-item ast-builder-language-switcher-item__active"> <?php } else { ?> <a href="<?php echo esc_url( $language['url'] ); ?>" class="ast-builder-language-switcher-item"> <?php } ?> <?php if ( $show_flag ) { ?> <span class="ast-lswitcher-item-<?php echo esc_attr( $builder_type ); ?>"><img src="<?php echo esc_url( $language['country_flag_url'] ); ?>" alt="<?php echo esc_attr( $language['language_code'] ); ?>" width="18" height="12" /></span> <?php } ?> <?php if ( $show_label ) { ?> <span class="ast-lswitcher-item-<?php echo esc_attr( $builder_type ); ?> ast-builder-language-switcher-native-name"><?php echo esc_html( $language['native_name'] ); ?></span> <?php } ?> <?php if ( $show_tname ) { ?> <span class="ast-lswitcher-item-<?php echo esc_attr( $builder_type ); ?> ast-builder-language-switcher-translated-name"><?php echo esc_html( $language['translated_name'] ); ?></span> <?php } ?> <?php if ( $show_code ) { ?> <span class="ast-lswitcher-item-<?php echo esc_attr( $builder_type ); ?> ast-builder-language-switcher-language-code"><?php echo '('; ?><?php echo esc_html( $language['language_code'] ); ?><?php echo ')'; ?></span> <?php } ?> </a> </li> <?php } ?> </ul></nav> <?php } } else { $items = astra_get_option( $index . '-options' ); $items = isset( $items['items'] ) ? $items['items'] : array(); $image_link = ''; if ( is_array( $items ) && ! empty( $items ) ) { ?> <nav class="ast-builder-language-switcher"><ul class="ast-builder-language-switcher-menu"> <?php foreach ( $items as $item ) { if ( $item['enabled'] ) { $link = ( '' !== $item['url'] ) ? $item['url'] : ''; ?> <li class="ast-builder-language-switcher-menu-item-<?php echo esc_attr( $builder_type ); ?>"> <a href="<?php echo esc_url( $link ); ?>" aria-label="<?php echo esc_attr( $item['label'] ); ?>" class="ast-builder-language-switcher-item"> <?php if ( $show_flag && 'zz-other' !== $item['id'] ) { ?> <span class="ast-lswitcher-item-<?php echo esc_attr( $builder_type ); ?>"> <?php echo self::fetch_flags_svg( $item['id'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> </span> <?php } ?> <?php if ( $show_label ) { ?> <span class="ast-lswitcher-item-<?php echo esc_attr( $builder_type ); ?> ast-builder-language-switcher-native-name"> <?php echo esc_html( $item['label'] ); ?></span> <?php } ?> </a> </li> <?php } } ?> </ul></nav> <?php } } ?> </div> </div> <?php }
Expand full source code Collapse full source code View on Trac