71 lines
2.0 KiB
PHP
71 lines
2.0 KiB
PHP
<?php
|
|
use Elementor\Controls_Manager;
|
|
use Elementor\Utils;
|
|
use Elementor\Icons_Manager;
|
|
// use Elementor\Group_Control_Text_Shadow;
|
|
// use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
|
|
// use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
|
|
// use Elementor\Group_Control_Text_Stroke;
|
|
// use Elementor\Group_Control_Typography;
|
|
class Elementor_Langswitcher extends \Elementor\Widget_Base {
|
|
|
|
public function get_name() {
|
|
return 'langswitcher';
|
|
}
|
|
|
|
public function get_title() {
|
|
return esc_html__( 'Langswitcher', 'elementor-addon' );
|
|
}
|
|
|
|
public function get_icon() {
|
|
return 'eicon-code';
|
|
}
|
|
|
|
public function get_categories() {
|
|
return [ 'basic' ];
|
|
}
|
|
|
|
public function get_keywords() {
|
|
return [ 'language'];
|
|
}
|
|
|
|
protected function register_controls() {
|
|
$this->start_controls_section(
|
|
'section_settings',
|
|
[
|
|
'label' => esc_html__( 'Language settings', 'elementor' ),
|
|
]
|
|
);
|
|
|
|
$this->end_controls_section();
|
|
}
|
|
|
|
protected function render() {
|
|
$settings = $this->get_settings_for_display();
|
|
$languages = apply_filters( 'wpml_active_languages', NULL, 'skip_missing=0&orderby=code' );
|
|
$current_language = ICL_LANGUAGE_CODE;
|
|
|
|
if ( !empty( $languages ) ) : ?>
|
|
<div id="language_box">
|
|
<div class="current-lang">
|
|
<span class="current-lang-flag">
|
|
<?php echo esc_html( strtoupper( $current_language ) ); ?>
|
|
</span>
|
|
</div>
|
|
<div class="lang-list">
|
|
<div class="lang-list--wrapper">
|
|
<?php foreach ( $languages as $language ) : ?>
|
|
<?php if ( $language['language_code'] != $current_language ) : ?>
|
|
<a href="<?php echo esc_url( $language['url'] ); ?>">
|
|
<span class="lang-flag">
|
|
<?php echo esc_html( strtoupper( $language['language_code'] ) ); ?>
|
|
</span>
|
|
</a>
|
|
<?php endif; ?>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endif;
|
|
}
|
|
}
|