<?php
namespace ElementorPro\Modules\NavMenu\Widgets;
use Elementor\Controls_Manager;
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
use Elementor\Core\Responsive\Responsive;
use Elementor\Group_Control_Border;
use Elementor\Group_Control_Box_Shadow;
use Elementor\Group_Control_Typography;
use ElementorPro\Base\Base_Widget;
use ElementorPro\Plugin;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class Nav_Menu extends Base_Widget {
protected $nav_menu_index = 1;
public function get_name() {
return 'nav-menu';
}
public function get_title() {
return __( 'Nav Menu', 'elementor-pro' );
}
public function get_icon() {
return 'eicon-nav-menu';
}
public function get_categories() {
return [ 'pro-elements', 'theme-elements' ];
}
public function get_keywords() {
return [ 'menu', 'nav', 'button' ];
}
public function get_script_depends() {
return [ 'smartmenus' ];
}
public function on_export( $element ) {
unset( $element['settings']['menu'] );
return $element;
}
protected function get_nav_menu_index() {
return $this->nav_menu_index++;
}
private function get_available_menus() {
$menus = wp_get_nav_menus();
$options = [];
foreach ( $menus as $menu ) {
$options[ $menu->slug ] = $menu->name;
}
return $options;
}
protected function register_controls() {
$this->start_controls_section(
'section_layout',
[
'label' => __( 'Layout', 'elementor-pro' ),
]
);
$menus = $this->get_available_menus();
if ( ! empty( $menus ) ) {
$this->add_control(
'menu',
[
'label' => __( 'Menu', 'elementor-pro' ),
'type' => Controls_Manager::SELECT,
'options' => $menus,
'default' => array_keys( $menus )[0],
'save_default' => true,
'separator' => 'after',
'description' => sprintf( __( 'Go to the <a href="%s" target="_blank">Menus screen</a> to manage your menus.', 'elementor-pro' ), admin_url( 'nav-menus.php' ) ),
]
);
} else {
$this->add_control(
'menu',
[
'type' => Controls_Manager::RAW_HTML,
'raw' => '<strong>' . __( 'There are no menus in your site.', 'elementor-pro' ) . '</strong><br>' . sprintf( __( 'Go to the <a href="%s" target="_blank">Menus screen</a> to create one.', 'elementor-pro' ), admin_url( 'nav-menus.php?action=edit&menu=0' ) ),
'separator' => 'after',
'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
]
);
}
$this->add_control(
'layout',
[
'label' => __( 'Layout', 'elementor-pro' ),
'type' => Controls_Manager::SELECT,
'default' => 'horizontal',
'options' => [
'horizontal' => __( 'Horizontal', 'elementor-pro' ),
'vertical' => __( 'Vertical', 'elementor-pro' ),
'dropdown' => __( 'Dropdown', 'elementor-pro' ),
],
'frontend_available' => true,
]
);
$this->add_control(
'align_items',
[
'label' => __( 'Align', 'elementor-pro' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __( 'Left', 'elementor-pro' ),
'icon' => 'eicon-h-align-left',
],
'center' => [
'title' => __( 'Center', 'elementor-pro' ),
'icon' => 'eicon-h-align-center',
],
'right' => [
'title' => __( 'Right', 'elementor-pro' ),
'icon' => 'eicon-h-align-right',
],
'justify' => [
'title' => __( 'Stretch', 'elementor-pro' ),
'icon' => 'eicon-h-align-stretch',
],
],
'prefix_class' => 'elementor-nav-menu__align-',
'condition' => [
'layout!' => 'dropdown',
],
]
);
$this->add_control(
'pointer',
[
'label' => __( 'Pointer', 'elementor-pro' ),
'type' => Controls_Manager::SELECT,
'default' => 'underline',
'options' => [
'none' => __( 'None', 'elementor-pro' ),
'underline' => __( 'Underline', 'elementor-pro' ),
'overline' => __( 'Overline', 'elementor-pro' ),
'double-line' => __( 'Double Line', 'elementor-pro' ),
'framed' => __( 'Framed', 'elementor-pro' ),
'background' => __( 'Background', 'elementor-pro' ),
'text' => __( 'Text', 'elementor-pro' ),
],
'style_transfer' => true,
'condition' => [
'layout!' => 'dropdown',
],
]
);
$this->add_control(
'animation_line',
[
'label' => __( 'Animation', 'elementor-pro' ),
'type' => Controls_Manager::SELECT,
'default' => 'fade',
'options' => [
'fade' => 'Fade',
'slide' => 'Slide',
'grow' => 'Grow',
'drop-in' => 'Drop In',
'drop-out' => 'Drop Out',
'none' => 'None',
],
'condition' => [
'layout!' => 'dropdown',
'pointer' => [ 'underline', 'overline', 'double-line' ],
],
]
);
$this->add_control(
'animation_framed',
[
'label' => __( 'Animation', 'elementor-pro' ),
'type' => Controls_Manager::SELECT,
'default' => 'fade',
'options' => [
'fade' => 'Fade',
'grow' => 'Grow',
'shrink' => 'Shrink',
'draw' => 'Draw',
'corners' => 'Corners',
'none' => 'None',
],
'condition' => [
'layout!' => 'dropdown',
'pointer' => 'framed',
],
]
);
$this->add_control(
'animation_background',
[
'label' => __( 'Animation', 'elementor-pro' ),
'type' => Controls_Manager::SELECT,
'default' => 'fade',
'options' => [
'fade' => 'Fade',
'grow' => 'Grow',
'shrink' => 'Shrink',
'sweep-left' => 'Sweep Left',
'sweep-right' => 'Sweep Right',
'sweep-up' => 'Sweep Up',
'sweep-down' => 'Sweep Down',
'shutter-in-vertical' => 'Shutter In Vertical',
'shutter-out-vertical' => 'Shutter Out Vertical',
'shutter-in-horizontal' => 'Shutter In Horizontal',
'shutter-out-horizontal' => 'Shutter Out Horizontal',
'none' => 'None',
],
'condition' => [
'layout!' => 'dropdown',
'pointer' => 'background',
],
]
);
$this->add_control(
'animation_text',
[
'label' => __( 'Animation', 'elementor-pro' ),
'type' => Controls_Manager::SELECT,
'default' => 'grow',
'options' => [
'grow' => 'Grow',
'shrink' => 'Shrink',
'sink' => 'Sink',
'float' => 'Float',
'skew' => 'Skew',
'rotate' => 'Rotate',
'none' => 'None',
],
'condition' => [
'layout!' => 'dropdown',
'pointer' => 'text',
],
]
);
$this->add_control(
'indicator',
[
'label' => __( 'Submenu Indicator', 'elementor-pro' ),
'type' => Controls_Manager::SELECT,
'default' => 'classic',
'options' => [
'none' => __( 'None', 'elementor-pro' ),
'classic' => __( 'Classic', 'elementor-pro' ),
'chevron' => __( 'Chevron', 'elementor-pro' ),
'angle' => __( 'Angle', 'elementor-pro' ),
'plus' => __( 'Plus', 'elementor-pro' ),
],
'prefix_class' => 'elementor-nav-menu--indicator-',
]
);
$this->add_control(
'heading_mobile_dropdown',
[
'label' => __( 'Mobile Dropdown', 'elementor-pro' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
'condition' => [
'layout!' => 'dropdown',
],
]
);
$breakpoints = Responsive::get_breakpoints();
$this->add_control(
'dropdown',
[
'label' => __( 'Breakpoint', 'elementor-pro' ),
'type' => Controls_Manager::SELECT,
'default' => 'tablet',
'options' => [
/* translators: %d: Breakpoint number. */
'mobile' => sprintf( __( 'Mobile (< %dpx)', 'elementor-pro' ), $breakpoints['md'] ),
/* translators: %d: Breakpoint number. */
'tablet' => sprintf( __( 'Tablet (< %dpx)', 'elementor-pro' ), $breakpoints['lg'] ),
'none' => __( 'None', 'elementor-pro' ),
],
'prefix_class' => 'elementor-nav-menu--dropdown-',
'condition' => [
'layout!' => 'dropdown',
],
]
);
$this->add_control(
'full_width',
[
'label' => __( 'Full Width', 'elementor-pro' ),
'type' => Controls_Manager::SWITCHER,
'description' => __( 'Stretch the dropdown of the menu to full width.', 'elementor-pro' ),
'prefix_class' => 'elementor-nav-menu--',
'return_value' => 'stretch',
'frontend_available' => true,
'condition' => [
'dropdown!' => 'none',
],
]
);
$this->add_control(
'text_align',
[
'label' => __( 'Align', 'elementor-pro' ),
'type' => Controls_Manager::SELECT,
'default' => 'aside',
'options' => [
'aside' => __( 'Aside', 'elementor-pro' ),
'center' => __( 'Center', 'elementor-pro' ),
],
'prefix_class' => 'elementor-nav-menu__text-align-',
'condition' => [
'dropdown!' => 'none',
],
]
);
$this->add_control(
Loading ...