start_controls_section( 'style_content_section', [ 'label' => esc_html__( 'Menu Location', 'megamenu' ) ] ); $locations = get_registered_nav_menus(); if ( ! empty( $locations ) ) { $this->add_control( 'location', array( 'label' => __( 'Choose Location', 'megamenu' ), 'type' => \Elementor\Controls_Manager::SELECT, 'options' => $locations, 'default' => array_keys( $locations )[0], 'save_default' => true ) ); } else { $this->add_control( 'location', array( 'type' => \Elementor\Controls_Manager::RAW_HTML, 'raw' => sprintf( __( 'Go to the Menu Locations page to create your first menu location.', 'megamenu' ), admin_url( 'admin.php?page=maxmegamenu' ) ), 'separator' => 'after', 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info', ) ); } $this->end_controls_section(); } /** * Render list widget output on the frontend. * * Written in PHP and used to generate the final HTML. * * @since 3.5 * @access protected */ protected function render() { $available_menus = get_registered_nav_menus(); if ( ! $available_menus ) { return; } $settings = $this->get_active_settings(); if ( ! empty( $settings['location'] ) ) { wp_nav_menu( array( 'theme_location' => $settings['location'], 'echo' => true, ) ); } } }