startControlsSection( 'section_layout', [ 'label' => __('Currency Selector'), ] ); $this->addControl( 'skin', [ 'label' => __('Skin'), 'type' => ControlsManager::SELECT, 'default' => 'dropdown', 'options' => [ 'classic' => __('Classic'), 'dropdown' => __('Dropdown'), ], 'separator' => 'after', ] ); $this->addControl( 'content', [ 'label' => __('Content'), 'label_block' => true, 'type' => ControlsManager::SELECT2, 'default' => ['symbol', 'code'], 'options' => [ 'symbol' => __('Symbol'), 'code' => __('ISO Code'), 'name' => __('Currency'), ], 'multiple' => true, ] ); $this->addControl( 'show_current', [ 'label' => __('Current Currency'), 'type' => ControlsManager::SWITCHER, 'label_on' => __('Show'), 'label_off' => __('Hide'), 'prefix_class' => 'elementor-nav--', 'return_value' => 'active', ] ); $this->registerNavContentControls([ 'layout_options' => [ 'horizontal' => __('Horizontal'), 'vertical' => __('Vertical'), ], 'submenu_condition' => [ 'skin' => 'dropdown', ], ]); $this->endControlsSection(); $this->registerNavStyleSection([ 'active_condition' => [ 'show_current!' => '', ], 'space_between_condition' => [ 'skin' => 'classic', ], ]); $this->registerDropdownStyleSection([ 'dropdown_condition' => [ 'skin' => 'dropdown', ], 'active_condition' => [ 'show_current!' => '', ], ]); } protected function getHtmlWrapperClass() { return parent::getHtmlWrapperClass() . ' elementor-widget-nav-menu'; } /** * Render currency selector widget output on the frontend. * * Written in PHP and used to generate the final HTML. * * @since 2.5.0 * @access protected * @codingStandardsIgnoreStart Generic.Files.LineLength */ protected function render() { $settings = $this->getActiveSettings(); $currencies = \Currency::getCurrencies(false, true, true); if (\Configuration::isCatalogMode() || count($currencies) <= 1 || !$settings['content']) { return; } $this->indicator = $settings['indicator']; $this->currency_symbol = in_array('symbol', $settings['content']); $this->currency_code = in_array('code', $settings['content']); $this->currency_name = in_array('name', $settings['content']); $url = preg_replace('/[&\?](SubmitCurrency|id_currency)=[^&]*/', '', $_SERVER['REQUEST_URI']); $separator = strrpos($url, '?') === false ? '?' : '&'; $id_currency = $this->context->currency->id; $menu = [ '0' => [ 'id' => $id_currency, 'symbol' => $this->context->currency->symbol, 'iso_code' => $this->context->currency->iso_code, 'name' => $this->context->currency->name, 'url' => 'javascript:;', 'current' => false, 'children' => [], ] ]; foreach ($currencies as &$currency) { $currency['current'] = $id_currency == $currency['id']; $currency['url'] = $url . $separator . 'SubmitCurrency=1&id_currency=' . (int) $currency['id']; $menu[0]['children'][] = $currency; } if ('classic' === $settings['skin']) { $menu = &$menu[0]['children']; } $ul_class = 'elementor-nav'; if ('vertical' === $settings['layout']) { $ul_class .= ' sm-vertical'; } // General Menu. ob_start(); $this->selectorList($menu, 0, $ul_class); $menu_html = ob_get_clean(); $this->addRenderAttribute('main-menu', 'class', [ 'elementor-currencies', 'elementor-nav--main', 'elementor-nav__container', 'elementor-nav--layout-' . $settings['layout'], ]); if ('none' !== $settings['pointer']) { $animation_type = self::getPointerAnimationType($settings['pointer']); $this->addRenderAttribute('main-menu', 'class', [ 'e--pointer-' . $settings['pointer'], 'e--animation-' . $settings[$animation_type], ]); } ?> context = \Context::getContext(); parent::__construct($data, $args); } }