name = esc_html__( 'Menu', 'et_builder' ); $this->plural = esc_html__( 'Menus', 'et_builder' ); $this->slug = self::$menu_slug; $this->vb_support = 'on'; $this->main_css_element = '%%order_class%%.' . self::$menu_slug; $this->settings_modal_toggles = array( 'general' => array( 'toggles' => array( 'main_content' => et_builder_i18n( 'Content' ), 'image' => esc_html__( 'Logo', 'et_builder' ), 'elements' => et_builder_i18n( 'Elements' ), ), ), 'advanced' => array( 'toggles' => array( 'layout' => array( 'title' => et_builder_i18n( 'Layout' ), 'priority' => 19, ), 'menu' => array( 'title' => esc_html__( 'Menu Text', 'et_builder' ), 'priority' => 29, ), 'dropdown' => array( 'title' => esc_html__( 'Dropdown Menu', 'et_builder' ), 'priority' => 39, ), 'icon_settings' => array( 'title' => esc_html__( 'Icons', 'et_builder' ), 'priority' => 49, ), 'image_settings' => array( 'title' => esc_html__( 'Logo', 'et_builder' ), 'priority' => 59, ), ), ), 'custom_css' => array( 'toggles' => array( 'animation' => array( 'title' => esc_html__( 'Animation', 'et_builder' ), 'priority' => 90, ), 'attributes' => array( 'title' => esc_html__( 'Attributes', 'et_builder' ), 'priority' => 95, ), ), ), ); $this->advanced_fields = array( 'fonts' => array( 'menu' => array( 'label' => esc_html__( 'Menu', 'et_builder' ), 'css' => array( 'main' => "{$this->main_css_element} ul li a", 'limited_main' => "{$this->main_css_element} ul li a, {$this->main_css_element} ul li", 'hover' => "{$this->main_css_element} ul li:hover > a", ), 'line_height' => array( 'default' => '1em', ), 'font_size' => array( 'default' => '14px', 'range_settings' => array( 'min' => '12', 'max' => '24', 'step' => '1', ), ), 'letter_spacing' => array( 'default' => '0px', 'range_settings' => array( 'min' => '0', 'max' => '8', 'step' => '1', ), ), 'hide_text_align' => true, ), ), 'background' => array( 'options' => array( 'background_color' => array( 'default' => '#ffffff', ), ), ), 'borders' => array( 'default' => array(), 'image' => array( 'css' => array( 'main' => array( 'border_radii' => '%%order_class%% .et_pb_menu__logo-wrap .et_pb_menu__logo img', 'border_styles' => '%%order_class%% .et_pb_menu__logo-wrap .et_pb_menu__logo img', ), ), 'label_prefix' => esc_html__( 'Logo', 'et_builder' ), 'tab_slug' => 'advanced', 'toggle_slug' => 'image_settings', ), ), 'box_shadow' => array( 'default' => array( 'css' => array( 'main' => '%%order_class%%, %%order_class%% .sub-menu', 'overlay' => 'inset', ), ), 'image' => array( 'label' => esc_html__( 'Logo Box Shadow', 'et_builder' ), 'option_category' => 'layout', 'tab_slug' => 'advanced', 'toggle_slug' => 'image_settings', 'css' => array( 'main' => '%%order_class%% .et_pb_menu__logo-wrap .et_pb_menu__logo', 'overlay' => 'inset', ), ), ), 'text' => array( 'use_background_layout' => true, 'toggle_slug' => 'menu', 'options' => array( 'text_orientation' => array( 'default_on_front' => 'left', 'depends_show_if' => 'left_aligned', 'depends_on' => array( 'menu_style', ), ), 'background_layout' => array( 'default_on_front' => 'light', 'hover' => 'tabs', ), ), ), 'filters' => array( 'child_filters_target' => array( 'tab_slug' => 'advanced', 'toggle_slug' => 'image_settings', 'css' => array( 'main' => '%%order_class%% .et_pb_menu__logo-wrap img', ), ), ), 'image' => array( 'css' => array( 'main' => '%%order_class%% .et_pb_menu__logo-wrap img', ), ), 'margin_padding' => array( 'css' => array( 'main' => '%%order_class%%', 'important' => array( 'custom_margin' ), ), ), 'button' => false, ); $this->custom_css_fields = array( 'menu_link' => array( 'label' => esc_html__( 'Menu Link', 'et_builder' ), 'selector' => '.et-menu-nav li a', ), 'active_menu_link' => array( 'label' => esc_html__( 'Active Menu Link', 'et_builder' ), 'selector' => '.et-menu-nav li.current-menu-item a', ), 'dropdown_container' => array( 'label' => esc_html__( 'Dropdown Menu Container', 'et_builder' ), 'selector' => '.et-menu-nav li ul.sub-menu', ), 'dropdown_links' => array( 'label' => esc_html__( 'Dropdown Menu Links', 'et_builder' ), 'selector' => '.et-menu-nav li ul.sub-menu a', ), 'menu_logo' => array( 'label' => esc_html__( 'Menu Logo', 'et_builder' ), 'selector' => '.et_pb_menu__logo', ), ); $this->help_videos = array( array( 'id' => 'Q2heZC2GbNg', 'name' => esc_html__( 'An introduction to the Menu module', 'et_builder' ), ), ); } function get_fields() { $et_accent_color = et_builder_accent_color(); $fields = array( 'menu_id' => array( 'label' => esc_html__( 'Menu', 'et_builder' ), 'type' => 'select', 'option_category' => 'basic_option', 'options' => et_builder_get_nav_menus_options(), 'description' => sprintf( '
%2$s. %3$s.
', esc_url( admin_url( 'nav-menus.php' ) ), esc_html__( 'Select a menu that should be used in the module', 'et_builder' ), esc_html__( 'Click here to create new menu', 'et_builder' ) ), 'toggle_slug' => 'main_content', 'computed_affects' => array( '__menu', ), ), 'menu_style' => array( 'label' => esc_html__( 'Style', 'et_builder' ), 'type' => 'select', 'option_category' => 'layout', 'options' => array( 'left_aligned' => esc_html__( 'Left Aligned', 'et_builder' ), 'centered' => esc_html__( 'Centered', 'et_builder' ), 'inline_centered_logo' => esc_html__( 'Inline Centered Logo', 'et_builder' ), ), 'default' => 'left_aligned', 'tab_slug' => 'advanced', 'toggle_slug' => 'layout', ), 'submenu_direction' => array( 'label' => esc_html__( 'Dropdown Menu Direction', 'et_builder' ), 'type' => 'select', 'option_category' => 'configuration', 'options' => array( 'downwards' => esc_html__( 'Downwards', 'et_builder' ), 'upwards' => esc_html__( 'Upwards', 'et_builder' ), ), 'tab_slug' => 'advanced', 'toggle_slug' => 'layout', 'description' => esc_html__( 'Here you can choose the direction that your sub-menus will open. You can choose to have them open downwards or upwards.', 'et_builder' ), 'computed_affects' => array( '__menu', ), ), 'active_link_color' => array( 'label' => esc_html__( 'Active Link Color', 'et_builder' ), 'description' => esc_html__( 'An active link is the page currently being visited. You can pick a color to be applied to active links to differentiate them from other links.', 'et_builder' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'menu', 'hover' => 'tabs', 'mobile_options' => true, 'sticky' => true, ), 'dropdown_menu_bg_color' => array( 'label' => esc_html__( 'Dropdown Menu Background Color', 'et_builder' ), 'description' => esc_html__( 'Pick a color to be applied to the background of dropdown menus. Dropdown menus appear when hovering over links with sub items.', 'et_builder' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'dropdown', 'hover' => 'tabs', 'sticky' => true, ), 'dropdown_menu_line_color' => array( 'label' => esc_html__( 'Dropdown Menu Line Color', 'et_builder' ), 'description' => esc_html__( 'Pick a color to be used for the dividing line between links in dropdown menus. Dropdown menus appear when hovering over links with sub items.', 'et_builder' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'dropdown', 'hover' => 'tabs', 'mobile_options' => true, 'sticky' => true, ), 'dropdown_menu_text_color' => array( 'label' => esc_html__( 'Dropdown Menu Text Color', 'et_builder' ), 'description' => esc_html__( 'Pick a color to be used for links in dropdown menus. Dropdown menus appear when hovering over links with sub items.', 'et_builder' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'dropdown', 'hover' => 'tabs', 'sticky' => true, ), 'dropdown_menu_active_link_color' => array( 'label' => esc_html__( 'Dropdown Menu Active Link Color', 'et_builder' ), 'description' => esc_html__( 'Pick a color to be used for active links in dropdown menus. Dropdown menus appear when hovering over links with sub items.', 'et_builder' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'dropdown', 'hover' => 'tabs', 'sticky' => true, ), 'mobile_menu_bg_color' => array( 'label' => esc_html__( 'Mobile Menu Background Color', 'et_builder' ), 'description' => esc_html__( 'Pick a unique color to be used for the menu background color when viewed on a mobile device.', 'et_builder' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'dropdown', 'hover' => 'tabs', 'mobile_options' => true, 'sticky' => true, ), 'mobile_menu_text_color' => array( 'label' => esc_html__( 'Mobile Menu Text Color', 'et_builder' ), 'description' => esc_html__( 'Pick a color to be used for links in mobile menus.', 'et_builder' ), 'type' => 'color-alpha', 'custom_color' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'dropdown', 'hover' => 'tabs', 'mobile_options' => true, 'sticky' => true, ), '__menu' => array( 'type' => 'computed', 'computed_callback' => array( 'ET_Builder_Module_Menu', 'get_fullwidth_menu' ), 'computed_depends_on' => array( 'menu_id', 'submenu_direction', ), ), 'logo' => array( 'label' => esc_html__( 'Logo', 'et_builder' ), 'type' => 'upload', 'option_category' => 'basic_option', 'upload_button_text' => et_builder_i18n( 'Upload an image' ), 'choose_text' => esc_attr__( 'Choose an Image', 'et_builder' ), 'update_text' => esc_attr__( 'Set As Logo', 'et_builder' ), 'description' => esc_html__( 'Upload an image to display beside your menu.', 'et_builder' ), 'toggle_slug' => 'image', 'dynamic_content' => 'image', 'mobile_options' => true, 'hover' => 'tabs', ), 'logo_url' => array( 'label' => esc_html__( 'Logo Link URL', 'et_builder' ), 'type' => 'text', 'option_category' => 'basic_option', 'description' => esc_html__( 'If you would like to make your logo a link, input your destination URL here.', 'et_builder' ), 'toggle_slug' => 'link_options', 'dynamic_content' => 'url', ), 'logo_url_new_window' => array( 'label' => esc_html__( 'Logo Link Target', 'et_builder' ), 'type' => 'select', 'option_category' => 'configuration', 'options' => array( 'off' => esc_html__( 'In The Same Window', 'et_builder' ), 'on' => esc_html__( 'In The New Tab', 'et_builder' ), ), 'toggle_slug' => 'link_options', 'description' => esc_html__( 'Here you can choose whether or not your link opens in a new window', 'et_builder' ), 'default_on_front' => 'off', ), 'logo_alt' => array( 'label' => esc_html__( 'Logo Alt Text', 'et_builder' ), 'type' => 'text', 'option_category' => 'basic_option', 'description' => esc_html__( 'Define the HTML ALT text for your logo here.', 'et_builder' ), 'tab_slug' => 'custom_css', 'toggle_slug' => 'attributes', 'dynamic_content' => 'text', ), 'logo_width' => array( 'label' => esc_html__( 'Logo Width', 'et_builder' ), 'description' => esc_html__( 'Adjust the width of the logo.', 'et_builder' ), 'type' => 'range', 'option_category' => 'layout', 'tab_slug' => 'advanced', 'toggle_slug' => 'width', 'mobile_options' => true, 'validate_unit' => true, 'allowed_values' => et_builder_get_acceptable_css_string_values( 'width' ), 'default' => 'auto', 'default_unit' => '%', 'range_settings' => array( 'min' => '0', 'max' => '100', 'step' => '1', ), 'responsive' => true, 'hover' => 'tabs', 'sticky' => true, ), 'logo_max_width' => array( 'label' => esc_html__( 'Logo Max Width', 'et_builder' ), 'description' => esc_html__( 'Adjust the maximum width of the logo.', 'et_builder' ), 'type' => 'range', 'option_category' => 'layout', 'tab_slug' => 'advanced', 'toggle_slug' => 'width', 'mobile_options' => true, 'validate_unit' => true, 'allowed_values' => et_builder_get_acceptable_css_string_values( 'max-width' ), 'default' => '100%', 'default_unit' => '%', 'range_settings' => array( 'min' => '0', 'max' => '100', 'step' => '1', ), 'responsive' => true, 'hover' => 'tabs', 'sticky' => true, ), 'logo_height' => array( 'label' => esc_html__( 'Logo Height', 'et_builder' ), 'description' => esc_html__( 'Adjust the height of the logo.', 'et_builder' ), 'type' => 'range', 'option_category' => 'layout', 'tab_slug' => 'advanced', 'toggle_slug' => 'width', 'mobile_options' => true, 'validate_unit' => true, 'allowed_values' => et_builder_get_acceptable_css_string_values( 'height' ), 'default' => 'auto', 'default_unit' => 'px', 'range_settings' => array( 'min' => '0', 'max' => '200', 'step' => '1', ), 'responsive' => true, 'hover' => 'tabs', 'sticky' => true, ), 'logo_max_height' => array( 'label' => esc_html__( 'Logo Max Height', 'et_builder' ), 'description' => esc_html__( 'Adjust the maximum height of the logo.', 'et_builder' ), 'type' => 'range', 'option_category' => 'layout', 'tab_slug' => 'advanced', 'toggle_slug' => 'width', 'mobile_options' => true, 'validate_unit' => true, 'allowed_values' => et_builder_get_acceptable_css_string_values( 'max-height' ), 'default' => 'none', 'default_unit' => 'px', 'range_settings' => array( 'min' => '0', 'max' => '200', 'step' => '1', ), 'responsive' => true, 'hover' => 'tabs', 'sticky' => true, ), 'show_cart_icon' => array( 'label' => esc_html__( 'Show Shopping Cart Icon', 'et_builder' ), 'type' => 'yes_no_button', 'option_category' => 'layout', 'options' => array( 'on' => et_builder_i18n( 'Yes' ), 'off' => et_builder_i18n( 'No' ), ), 'default' => 'off', 'toggle_slug' => 'elements', 'mobile_options' => true, 'responsive' => true, 'hover' => 'tabs', 'sticky' => true, ), 'show_search_icon' => array( 'label' => esc_html__( 'Show Search Icon', 'et_builder' ), 'type' => 'yes_no_button', 'option_category' => 'layout', 'options' => array( 'on' => et_builder_i18n( 'Yes' ), 'off' => et_builder_i18n( 'No' ), ), 'default' => 'off', 'toggle_slug' => 'elements', 'mobile_options' => true, 'responsive' => true, 'hover' => 'tabs', 'sticky' => true, ), 'cart_icon_color' => array( 'default' => $et_accent_color, 'label' => esc_html__( 'Shopping Cart Icon Color', 'et_builder' ), 'type' => 'color-alpha', 'description' => esc_html__( 'Here you can define a custom color for your shopping cart icon.', 'et_builder' ), 'tab_slug' => 'advanced', 'toggle_slug' => 'icon_settings', 'hover' => 'tabs', 'mobile_options' => true, 'sticky' => true, ), 'search_icon_color' => array( 'default' => $et_accent_color, 'label' => esc_html__( 'Search Icon Color', 'et_builder' ), 'type' => 'color-alpha', 'description' => esc_html__( 'Here you can define a custom color for your search icon.', 'et_builder' ), 'tab_slug' => 'advanced', 'toggle_slug' => 'icon_settings', 'hover' => 'tabs', 'mobile_options' => true, 'sticky' => true, ), 'menu_icon_color' => array( 'default' => $et_accent_color, 'label' => esc_html__( 'Hamburger Menu Icon Color', 'et_builder' ), 'type' => 'color-alpha', 'description' => esc_html__( 'Here you can define a custom color for your hamburger menu icon.', 'et_builder' ), 'tab_slug' => 'advanced', 'toggle_slug' => 'icon_settings', 'hover' => 'tabs', 'mobile_options' => true, 'sticky' => true, ), 'cart_icon_font_size' => array( 'label' => esc_html__( 'Shopping Cart Icon Font Size', 'et_builder' ), 'description' => esc_html__( 'Control the size of the icon by increasing or decreasing the font size.', 'et_builder' ), 'type' => 'range', 'option_category' => 'font_option', 'tab_slug' => 'advanced', 'toggle_slug' => 'icon_settings', 'default' => '17px', 'default_unit' => 'px', 'default_on_front' => '', 'allowed_units' => et_builder_get_acceptable_css_string_values( 'font-size' ), 'range_settings' => array( 'min' => '1', 'max' => '120', 'step' => '1', ), 'mobile_options' => true, 'responsive' => true, 'sticky' => true, 'hover' => 'tabs', ), 'search_icon_font_size' => array( 'label' => esc_html__( 'Search Icon Font Size', 'et_builder' ), 'description' => esc_html__( 'Control the size of the icon by increasing or decreasing the font size.', 'et_builder' ), 'type' => 'range', 'option_category' => 'font_option', 'tab_slug' => 'advanced', 'toggle_slug' => 'icon_settings', 'default' => '17px', 'default_unit' => 'px', 'default_on_front' => '', 'allowed_units' => et_builder_get_acceptable_css_string_values( 'font-size' ), 'range_settings' => array( 'min' => '1', 'max' => '120', 'step' => '1', ), 'mobile_options' => true, 'responsive' => true, 'sticky' => true, 'hover' => 'tabs', ), 'menu_icon_font_size' => array( 'label' => esc_html__( 'Hamburger Menu Icon Font Size', 'et_builder' ), 'description' => esc_html__( 'Control the size of the icon by increasing or decreasing the font size.', 'et_builder' ), 'type' => 'range', 'option_category' => 'font_option', 'tab_slug' => 'advanced', 'toggle_slug' => 'icon_settings', 'default' => '32px', 'default_unit' => 'px', 'default_on_front' => '', 'allowed_units' => et_builder_get_acceptable_css_string_values( 'font-size' ), 'range_settings' => array( 'min' => '1', 'max' => '120', 'step' => '1', ), 'mobile_options' => true, 'responsive' => true, 'sticky' => true, 'hover' => 'tabs', ), ); return $fields; } public function get_transition_fields_css_props() { $menu_slug = self::$menu_slug; $fields = parent::get_transition_fields_css_props(); $fields['active_link_color'] = array( 'color' => "%%order_class%%.{$menu_slug} ul li.current-menu-item a" ); $fields['dropdown_menu_text_color'] = array( 'color' => "%%order_class%%.{$menu_slug} .nav li ul a" ); $fields['dropdown_menu_active_link_color'] = array( 'color' => "%%order_class%%.{$menu_slug} .nav li ul li.current-menu-item a" ); $fields['logo_width'] = array( 'width' => '%%order_class%% .et_pb_menu_inner_container > .et_pb_menu__logo-wrap .et_pb_menu__logo, %%order_class%% .et_pb_menu__logo-slot' ); $fields['logo_max_width'] = array( 'max-width' => '%%order_class%% .et_pb_menu_inner_container > .et_pb_menu__logo-wrap .et_pb_menu__logo, %%order_class%% .et_pb_menu__logo-slot' ); $fields['logo_height'] = array( 'height' => '%%order_class%% .et_pb_menu_inner_container > .et_pb_menu__logo-wrap .et_pb_menu__logo img, %%order_class%% .et_pb_menu__logo-slot .et_pb_menu__logo-wrap img' ); $fields['logo_max_height'] = array( 'max-height' => '%%order_class%% .et_pb_menu_inner_container > .et_pb_menu__logo-wrap .et_pb_menu__logo img, %%order_class%% .et_pb_menu__logo-slot .et_pb_menu__logo-wrap img' ); $fields['menu_icon_color'] = array( 'color' => '%%order_class%% .mobile_menu_bar:before', ); $fields['search_icon_color'] = array( 'color' => '%%order_class%% .et_pb_menu__icon.et_pb_menu__search-button, %%order_class%% .et_pb_menu__icon.et_pb_menu__close-search-button', ); $fields['cart_icon_color'] = array( 'color' => '%%order_class%% .et_pb_menu__icon.et_pb_menu__cart-button', ); $fields['menu_icon_font_size'] = array( 'font-size' => '%%order_class%% .mobile_menu_bar:before', ); $fields['search_icon_font_size'] = array( 'font-size' => '%%order_class%% .et_pb_menu__icon.et_pb_menu__search-button, %%order_class%% .et_pb_menu__icon.et_pb_menu__close-search-button', ); $fields['cart_icon_font_size'] = array( 'font-size' => '%%order_class%% .et_pb_menu__icon.et_pb_menu__cart-button', ); return $fields; } /** * Add the class with page ID to menu item so it can be easily found by ID in Frontend Builder * * @return menu item object */ static function modify_fullwidth_menu_item( $menu_item ) { // Since PHP 7.1 silent conversion to array is no longer supported. $menu_item->classes = (array) $menu_item->classes; if ( esc_url( home_url( '/' ) ) === $menu_item->url ) { $fw_menu_custom_class = 'et_pb_menu_page_id-home'; } else { $fw_menu_custom_class = 'et_pb_menu_page_id-' . $menu_item->object_id; } $menu_item->classes[] = $fw_menu_custom_class; return $menu_item; } /** * Get menu markup for menu module * * @return string of menu markup */ static function get_fullwidth_menu( $args = array() ) { $is_fullwidth = 'et_pb_fullwidth_menu' === self::$menu_slug; $defaults = array( 'submenu_direction' => '', 'menu_id' => '', ); // modify the menu item to include the required data add_filter( 'wp_setup_nav_menu_item', array( 'ET_Builder_Module_Menu', 'modify_fullwidth_menu_item' ) ); $args = wp_parse_args( $args, $defaults ); $menu = '