<?php

namespace WPML\PB\Elementor\LanguageSwitcher;

use Elementor\Plugin;

class LanguageSwitcher implements \IWPML_Backend_Action, \IWPML_Frontend_Action {

	public function add_hooks() {
		if ( version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' ) ) {
			add_action( 'elementor/widgets/register', [ $this, 'registerWidgets' ] );
		} else {
			add_action( 'elementor/widgets/widgets_registered', [ $this, 'registerWidgetsDeprecated' ] );
		}

		add_filter( 'wpml_custom_language_switcher_is_enabled', '__return_true' );
	}

	public function registerWidgets() {
		Plugin::instance()->widgets_manager->register( new Widget() );
	}

	public function registerWidgetsDeprecated() {
		Plugin::instance()->widgets_manager->register_widget_type( new Widget() );
	}
}
