name = esc_html__( 'Menu Item', 'dd_builder' ); $this->type = 'child'; $this->child_title_var = 'title'; $this->main_css_element = '%%order_class%%'; $this->settings_modal_toggles = array( 'general' => array( 'toggles' => array( 'main_content' => esc_html__( 'Menu Item', 'dd_builder' ), 'cart' => esc_html__( 'Shopping Cart', 'dd_builder' ), 'item_link' => et_builder_i18n( 'Content' ), ), ), 'advanced' => array( 'toggles' => array( 'item_text' => sprintf( '%1$s %2$s', esc_html__( 'Menu Item', 'et_builder' ), et_builder_i18n( 'Text' ) ), 'item_icon' => sprintf( '%1$s %2$s', esc_html__( 'Menu Item', 'et_builder' ), esc_html__( 'Image & Icon', 'et_builder' ) ), 'toggle_icon' => sprintf( '%1$s %2$s', esc_html__( 'Toggle', 'et_builder' ), et_builder_i18n( 'Icon' ) ), 'cart' => esc_html__( 'Shopping Cart', 'dd_builder' ), 'item_link' => et_builder_i18n( 'Content' ), 'wp_menu' => esc_html__( 'WordPress Menu', 'dd_builder' ), 'link_icon' => sprintf( '%1$s %2$s', et_builder_i18n( 'Content' ), esc_html__( 'Image & Icon', 'et_builder' ) ), 'title' => sprintf( '%1$s %2$s', et_builder_i18n( 'Content' ), et_builder_i18n( 'Title' ) ), 'body' => array( 'title' => sprintf( '%1$s %2$s', et_builder_i18n( 'Content' ), et_builder_i18n( 'Body' ) ), 'tabbed_subtoggles' => true, 'bb_icons_support' => true, 'sub_toggles' => array( 'p' => array( 'name' => 'P', 'icon' => 'text-left', ), 'a' => array( 'name' => 'A', 'icon' => 'text-link', ), 'ul' => array( 'name' => 'UL', 'icon' => 'list', ), 'ol' => array( 'name' => 'OL', 'icon' => 'numbered-list', ), 'quote' => array( 'name' => 'QUOTE', 'icon' => 'text-quote', ), ), ), 'button' => sprintf( '%1$s %2$s', et_builder_i18n( 'Content' ), et_builder_i18n( 'Button' ) ), 'effects' => sprintf( '%1$s %2$s', et_builder_i18n( 'Content' ), esc_html__( 'Animation', 'et_builder' ) ), ), ), ); $this->custom_css_fields = array( 'popup' => array( 'label' => et_builder_i18n( 'Content' ), 'selector' => '%%order_class%%_popup .ddb-popup > div', 'show_if' => array( 'link_type' => array( 'popup_c', 'popup_l' ) ), ), 'sub' => array( 'label' => et_builder_i18n( 'Content' ), 'selector' => '%%order_class%% .ddb-item-wrapper .ddb-item-sub > *', 'show_if' => array( 'link_type' => array( 'sub_c', 'sub_l', 'sub_wp' ) ), ), 'cart_info' => array( 'label' => esc_html__( 'Cart Quantity', 'et_builder' ), 'selector' => '%%order_class%% .ddb-item .ddb-cart-info', 'show_if' => array( 'is_cart' => 'on', 'cart_quantity' => 'on' ) ), 'wp_item_css' => array( 'label' => esc_html__( 'WordPress Menu Item', 'dd_builder' ), 'selector' => '%%order_class%% .ddb-item-wrapper .ddb-item-sub .ddb-wp-item', 'show_if' => array( 'link_type' => 'sub_wp' ), ), 'wp_inner_css' => array( 'label' => esc_html__( 'WordPress Sub Menu Item', 'dd_builder' ), 'selector' => '%%order_class%% .ddb-item-sub ul ul .ddb-wp-item', 'show_if' => array('link_type' => 'sub_wp'), ), 'wp_collapse_css' => array( 'label' => esc_html__( 'WordPress Collapse Icon', 'dd_builder' ), 'selector' => '%%order_class%% .ddb-item-sub ul span.ddb-collapse', 'show_if' => array('link_type' => 'sub_wp', 'wp_collapse' => 'on'), ), 'content_icon_css' => array( 'label' => sprintf( '%1$s %2$s', et_builder_i18n( 'Content' ), et_builder_i18n( 'Image/Icon' ) ), 'selector' => '%%order_class%% .ddb-menu-item-image-icon, %%order_class%%_popup .ddb-menu-item-image-icon', 'show_if' => array( 'link_type' => array( 'sub_c', 'popup_c' ), 'cc_icon_image' => array( 'icon', 'image' ) ), ), 'content_title_css' => array( 'label' => sprintf( '%1$s %2$s', et_builder_i18n( 'Content' ), et_builder_i18n( 'Title' ) ), 'selector' => '%%order_class%% .ddb-menu-item-title, %%order_class%%_popup .ddb-menu-item-title', 'show_if' => array( 'link_type' => array( 'sub_c', 'popup_c' ), ), ), 'content_body_css' => array( 'label' => sprintf( '%1$s %2$s', et_builder_i18n( 'Content' ), et_builder_i18n( 'Body' ) ), 'selector' => '%%order_class%% .ddb-menu-item-body, %%order_class%%_popup .ddb-menu-item-body', 'show_if' => array( 'link_type' => array( 'sub_c', 'popup_c' ), ), ), ); add_filter('nav_menu_link_attributes', array($this, 'nav_menu_link_attrs'), 1, 3); add_filter('nav_menu_css_class', array($this, 'nav_menu_css_class'), 1, 3); } public function get_advanced_fields_config() { $advanced_fields = array( 'background' => array( 'css' => array( 'main' => "{$this->main_css_element} .ddb-item-wrapper > .ddb-item, {$this->main_css_element} .ddb-item-wrapper .ddb-wp-item", 'hover' => "{$this->main_css_element} .ddb-item-wrapper > .ddb-item:hover, {$this->main_css_element} .ddb-item-wrapper .ddb-wp-item:hover, {$this->main_css_element} .ddb-item-wrapper > .ddb-item.active, {$this->main_css_element} .ddb-item-wrapper .ddb-wp-item.active", ), 'use_background_mask' => false, 'use_background_pattern' => false, 'use_background_video' => false ), 'borders' => array( 'default' => array( 'css' => array( 'main' => array( 'border_radii' => "{$this->main_css_element} .ddb-item", 'border_styles' => "{$this->main_css_element} .ddb-item", ), ), ), ), 'box_shadow' => array( 'default' => array( 'css' => array( 'main' => "{$this->main_css_element} .ddb-item", ), ), ), 'button' => array( 'button' => array( 'label' => et_builder_i18n( 'Button' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-menu-item-button, {$this->main_css_element}_popup_inner .ddb-menu-item-button", 'alignment' => "{$this->main_css_element} .et_pb_button_module_wrapper, {$this->main_css_element}_popup .et_pb_button_module_wrapper", ), 'use_alignment' => true, 'box_shadow' => array( 'css' => array( 'main' => '%%order_class%% .ddb-menu-item-button, %%order_class%%_popup_inner .ddb-menu-item-button', ), ), 'depends_show_if' => array( 'sub_c', 'popup_c' ), 'toggle_slug' => 'button', ), ), 'fonts' => array( 'item' => array( 'label' => esc_html__( 'Menu Item', 'dd_builder' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-item .ddb-text, {$this->main_css_element} .ddb-item-wrapper .ddb-wp-item", 'hover' => "%%order_class%% .ddb-item:hover .ddb-text, %%order_class%% .ddb-item.active .ddb-text, %%order_class%% .ddb-wp-item:hover, %%order_class%% .ddb-wp-item.active", ), 'text_shadow' => array( 'show_if' => array( 'item_content' => 'text' ) ), 'hide_text_align' => true, 'depends_show_if' => 'text', 'toggle_slug' => 'item_text', ), 'wp' => array( 'label' => esc_html__( 'Menu Item' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-item-sub .ddb-wp-item", 'hover' => "{$this->main_css_element} .ddb-item-sub .ddb-wp-item:hover, {$this->main_css_element} .ddb-item-sub .ddb-wp-item:active", ), 'line_height' => array( 'default_on_child' => true, 'default' => '1.3em', ), 'text_align' => array( 'show_if' => array( 'link_type' => 'sub_wp' ) ), 'hide_text_shadow' => true, 'depends_show_if' => 'sub_wp', 'toggle_slug' => 'wp_menu' ), 'title' => array( 'label' => et_builder_i18n( 'Title' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-menu-item-title, {$this->main_css_element}_popup .ddb-menu-item-title", ), 'header_level' => array( 'default' => 'h4', ), 'text_shadow' => array( 'show_if' => array( 'link_type' => array( 'sub_c', 'popup_c') ) ), ), 'body' => array( 'label' => et_builder_i18n( 'Body' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-menu-item-body, {$this->main_css_element}_popup .ddb-menu-item-body", ), 'line_height' => array( 'default' => floatval( et_get_option( 'body_font_height', '1.7' ) ) . 'em', ), 'font_size' => array( 'default' => absint( et_get_option( 'body_font_size', '14' ) ) . 'px', ), 'text_shadow' => array( 'show_if' => array( 'link_type' => array( 'sub_c', 'popup_c') ) ), 'toggle_slug' => 'body', 'sub_toggle' => 'p', ), 'body_link' => array( 'label' => et_builder_i18n( 'Link' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-menu-item-body a, {$this->main_css_element}_popup .ddb-menu-item-body a", ), 'text_shadow' => array( 'show_if' => array( 'link_type' => array( 'sub_c', 'popup_c') ) ), 'toggle_slug' => 'body', 'sub_toggle' => 'a', ), 'body_ul' => array( 'label' => esc_html__( 'Unordered List', 'et_builder' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-menu-item-body ul li, {$this->main_css_element}_popup .ddb-menu-item-body ul li", 'item_indent' => "{$this->main_css_element} .ddb-menu-item-body ul, {$this->main_css_element}_popup .ddb-menu-item-body ul", ), 'text_shadow' => array( 'show_if' => array( 'link_type' => array( 'sub_c', 'popup_c') ) ), 'toggle_slug' => 'body', 'sub_toggle' => 'ul', ), 'body_ol' => array( 'label' => esc_html__( 'Ordered List', 'et_builder' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-menu-item-body ol li, {$this->main_css_element}_popup .ddb-menu-item-body ol li", 'item_indent' => "{$this->main_css_element} .ddb-menu-item-body ol, {$this->main_css_element}_popup .ddb-menu-item-body ol", ), 'text_shadow' => array( 'show_if' => array( 'link_type' => array( 'sub_c', 'popup_c') ) ), 'toggle_slug' => 'body', 'sub_toggle' => 'ol', ), 'body_quote' => array( 'label' => esc_html__( 'Blockquote', 'et_builder' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-menu-item-body blockquote, {$this->main_css_element}_popup .ddb-menu-item-body blockquote", ), 'text_shadow' => array( 'show_if' => array( 'link_type' => array( 'sub_c', 'popup_c') ) ), 'toggle_slug' => 'body', 'sub_toggle' => 'quote', ), ), 'image_icon' => array( 'image_icon' => array( 'label' => et_builder_i18n( 'Image/Icon' ), 'css' => array( 'main' => '%%order_class%% .ddb-menu-item-image-icon, %%order_class%%_popup .ddb-menu-item-image-icon', ), 'toggle_slug' => 'link_icon', ), 'toggle_icon' => array( 'label' => esc_html__( 'Toggle Icon', 'et_builder' ), 'css' => array( 'main' => '%%order_class%% .ddb-toggle-icon', ), 'margin_padding' => array( 'use_margin' => false, ), 'toggle_slug' => 'toggle_icon', ), 'popup' => array( 'label' => et_builder_i18n( 'Content' ), 'css' => array( 'main' => '%%order_class%%_popup .ddb-popup > div', ), 'margin_padding' => array( 'use_margin' => false, ), 'toggle_slug' => 'item_link', ), 'sub' => array( 'label' => et_builder_i18n( 'Content' ), 'css' => array( 'main' => '%%order_class%% .ddb-item-wrapper .ddb-item + .ddb-item-sub > *', ), 'margin_padding' => array( 'use_margin' => false, ), 'toggle_slug' => 'item_link', ), 'wp' => array( 'label' => esc_html__( 'Menu Item', 'dd_builder' ), 'css' => array( 'main' => '%%order_class%% .ddb-item-sub > ul a', ), 'margin_padding' => array( 'use_margin' => false, ), 'toggle_slug' => 'wp_menu', ), 'wp_inner' => array( 'label' => esc_html__( 'Sub Menu Item', 'dd_builder' ), 'css' => array( 'main' => '%%order_class%% .ddb-item-sub ul ul .ddb-wp-item', ), 'margin_padding' => array( 'use_margin' => false, ), 'toggle_slug' => 'wp_menu', ), ), 'margin_padding' => array( 'css' => array( 'main' => "{$this->main_css_element} .ddb-item", 'margin' => "{$this->main_css_element} .ddb-item-wrapper", 'important' => 'all', ), ), 'text' => false, 'text_shadow' => array( 'default' => false, ), 'link_options' => false, ); if ( $this->ecommerce_enabled() ) $advanced_fields['fonts']['cart_quantity'] = array( 'label' => esc_html__( 'Cart Quantity', 'et_builder' ), 'css' => array( 'main' => "{$this->main_css_element} .ddb-cart-info", ), 'font' => array( 'show_if' => array( 'item_content' => array( 'icon', 'image' ), 'is_cart' => 'on', 'cart_quantity' => 'on' ), ), 'font_size' => array( 'default' => '14px', 'show_if' => array( 'item_content' => array( 'icon', 'image' ), 'is_cart' => 'on', 'cart_quantity' => 'on' ), ), 'text_color' => array( 'show_if' => array( 'item_content' => array( 'icon', 'image' ), 'is_cart' => 'on', 'cart_quantity' => 'on' ) ), 'text_shadow' => array( 'show_if' => array( 'item_content' => array( 'icon', 'image' ), 'is_cart' => 'on', 'cart_quantity' => 'on' ) ), 'hide_letter_spacing' => true, 'hide_line_height' => true, 'hide_text_align' => true, 'depends_show_if' => 'on', 'toggle_slug' => 'cart', ); return $advanced_fields; } public function get_fields() { $helper = new DonDiviBuilderFields(); $fields = array( 'title' => array( 'label' => esc_html__( 'Title', 'et_builder' ), 'description' => esc_html__( 'Define the title for this Menu Item.', 'dd_builder' ), 'type' => 'text', 'default' => 'Item', 'hover' => 'tabs', 'toggle_slug' => 'main_content', 'dynamic_content' => 'text', ), 'item_content' => array( 'label' => et_builder_i18n( 'Content' ), 'type' => 'select', 'options' => array( 'icon' => esc_html__( 'Icon', 'et_builder' ), 'image' => esc_html__( 'Image', 'et_builder' ), 'text' => esc_html__( 'Text', 'et_builder' ), ), 'affects' => array('item_font', 'item_text_color', 'item_font_size', 'item_letter_spacing', 'item_line_height'), 'default' => 'text', 'toggle_slug' => 'main_content', ), 'text_icon_image' => array( 'label' => et_builder_i18n( 'Image/Icon' ), 'type' => 'multiple_buttons', 'options' => array( 'none' => array( 'title' => esc_html__('None', 'et_builder') ), 'icon' => array( 'title' => esc_html__('Icon', 'et_builder') ), 'image' => array( 'title' => esc_html__('Image', 'et_builder') ), ), 'default' => 'none', 'show_if' => array('item_content' => 'text'), 'toggle_slug' => 'main_content', ), 'text_font_icon' => array( 'label' => esc_html__( 'Icon', 'et_builder' ), 'type' => 'select_icon', 'class' => array( 'et-pb-font-icon' ), 'show_if' => array('item_content' => 'text', 'text_icon_image' => 'icon'), 'mobile_options' => true, 'hover' => 'tabs', 'toggle_slug' => 'main_content', ), 'text_image' => array( 'label' => esc_html__( 'Image', 'et_builder' ), 'type' => 'upload', 'upload_button_text'=> esc_attr__( 'Upload an image', 'et_builder' ), 'choose_text' => esc_attr__( 'Choose an Image', 'et_builder' ), 'update_text' => esc_attr__( 'Set As Image', 'et_builder' ), 'show_if' => array('item_content' => 'text', 'text_icon_image' => 'image'), 'mobile_options' => true, 'hover' => 'tabs', 'dynamic_content' => 'image', 'toggle_slug' => 'main_content', ), 'text_icon_position' => array( 'label' => esc_html__( 'Placement', 'et_builder' ), 'type' => 'select', 'options' => array( 'column' => esc_html__( 'Top', 'et_builder' ), 'row-reverse' => esc_html__( 'Right', 'et_builder' ), 'column-reverse' => esc_html__( 'Bottom', 'et_builder' ), 'row' => esc_html__( 'Left', 'et_builder' ), ), 'default' => 'row', 'show_if' => array('item_content' => 'text', 'text_icon_image' => array('icon', 'image')), 'toggle_slug' => 'main_content', ), 'link_type' => array( 'label' => esc_html__( 'Link Type', 'dd_builder' ), 'type' => 'select', 'options' => array( 'url' => esc_html( 'URL' ), 'popup_l' => esc_html( 'Popup (Divi Layout)' ), 'popup_c' => esc_html( 'Popup (Custom)' ), 'sub_l' => esc_html( 'Sub (Divi Layout)' ), 'sub_c' => esc_html( 'Sub (Custom)' ), 'sub_wp' => esc_html( 'Sub (WordPress Menu)' ), ), 'affects' => array( 'wp_font', 'wp_text_align', 'wp_text_color', 'wp_font_size', 'wp_letter_spacing', 'wp_line_height' ), 'default' => 'url', 'mobile_options' => true, 'toggle_slug' => 'item_link', ), 'divi_layout' => array( 'label' => esc_html__( 'Layout', 'et_builder' ), 'description' => esc_html__( 'Here you can choose the Divi Library saved layout.', 'dd_builder' ), 'type' => 'select', 'options' => $helper->get_layouts(), 'show_if' => array('link_type' => 'popup_l'), 'searchable' => true, 'displayRecent' => false, 'toggle_slug' => 'item_link', ), 'sub_preview' => array( 'label' => esc_html__( 'Preview in the Builder', 'dd_builder' ), 'description' => esc_html__( 'Toggle this field to temporarily preview the sub element while editing this Menu Item.', 'dd_builder' ), 'type' => 'yes_no_button', 'options' => $helper->get_yes_no_button_options(), 'default' => 'off', 'show_if' => array('link_type' => array('sub_c', 'sub_l', 'sub_wp')), 'toggle_slug' => 'item_link', ), 'text_icon_color' => array( 'label' => esc_html__( 'Icon Color', 'et_builder' ), 'type' => 'color-alpha', 'hover' => 'tabs', 'mobile_options' => true, 'sticky' => true, 'show_if' => array('item_content' => 'text', 'text_icon_image' => 'icon'), 'tab_slug' => 'advanced', 'toggle_slug' => 'item_icon', ), 'text_icon_size' => array( 'label' => esc_html__( 'Icon Size', 'et_builder' ), 'type' => 'range', 'default' => '24px', 'default_unit' => 'px', 'mobile_options' => true, 'sticky' => true, 'show_if' => array('item_content' => 'text', 'text_icon_image' => 'icon'), 'tab_slug' => 'advanced', 'toggle_slug' => 'item_icon', ), 'text_image_width' => array( 'label' => esc_html__( 'Image Width', 'et_builder' ), 'type' => 'range', 'allowed_values' => et_builder_get_acceptable_css_string_values( 'width' ), 'default' => '57px', 'default_unit' => 'px', 'validate_unit' => true, 'mobile_options' => true, 'sticky' => true, 'show_if' => array('item_content' => 'text', 'text_icon_image' => 'image'), 'tab_slug' => 'advanced', 'toggle_slug' => 'item_icon', ), 'item_font_icon' => array( 'label' => esc_html__( 'Icon', 'et_builder' ), 'type' => 'select_icon', 'class' => array( 'et-pb-font-icon' ), 'default' => 'L||divi||400', 'show_if' => array( 'item_content' => 'icon'), 'hover' => 'tabs', 'mobile_options' => 'tabs', 'toggle_slug' => 'main_content', ), 'item_image' => array( 'label' => esc_html__( 'Image', 'et_builder' ), 'type' => 'upload', 'upload_button_text'=> esc_attr__( 'Upload an image', 'et_builder' ), 'choose_text' => esc_attr__( 'Choose an Image', 'et_builder' ), 'update_text' => esc_attr__( 'Set As Image', 'et_builder' ), 'show_if' => array('item_content' => 'image'), 'mobile_options' => true, 'hover' => 'tabs', 'dynamic_content' => 'image', 'toggle_slug' => 'main_content', ), 'item_icon_color' => array( 'label' => esc_html__( 'Icon Color', 'et_builder' ), 'description' => esc_html__( 'Here you can define a custom color for your icon.', 'et_builder' ), 'type' => 'color-alpha', 'show_if' => array('item_content' => 'icon'), 'hover' => 'tabs', 'mobile_options' => true, 'sticky' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'item_icon', ), 'item_icon_width' => array( 'label' => esc_html__( 'Icon Size', 'et_builder' ), 'default' => '24px', 'type' => 'range', 'default_unit' => 'px', 'allowed_units' => array( '%', 'em', 'rem', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ex', 'vh', 'vw' ), 'show_if' => array('item_content' => 'icon'), 'mobile_options' => true, 'sticky' => true, 'hover' => 'tabs', 'tab_slug' => 'advanced', 'toggle_slug' => 'item_icon' ), 'item_image_width' => array( 'label' => esc_html__( 'Image Width', 'et_builder' ), 'type' => 'range', 'range_settings' => array( 'max' => 550, 'step' => 1 ), 'default' => '57px', 'allowed_values' => et_builder_get_acceptable_css_string_values( 'width' ), 'default_unit' => 'px', 'show_if' => array('item_content' => 'image'), 'mobile_options' => true, 'sticky' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'item_icon', ), 'inner_content_gap' => array( 'label' => esc_html__( 'Offset', 'dd_builder' ), 'type' => 'range', 'default' => '5px', 'default_unit' => 'px', 'show_if' => array('item_content' => 'text', 'text_icon_image' => array('icon', 'image')), 'mobile_options' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'item_icon', ), 'content_gap' => array( 'label' => esc_html__( 'Offset', 'dd_builder' ), 'type' => 'range', 'default' => '5px', 'default_unit' => 'px', 'show_if' => array( 'link_type' => array('sub_l', 'sub_c', 'sub_wp'), 'use_toggle_icon' => 'on' ), 'mobile_options' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'toggle_icon', ), ); $fields['item_alt'] = $helper->get_alt_field( array( 'item_content' => 'image' ), 'Image Alt Text' ); $fields['module_class'] = $helper->get_custom_class_field(); $cc_settings = array( 'content_slug' => 'item_link', 'link_slug' => 'item_link', 'icon' => true, 'icon_slug' => 'link_icon', 'button' => true, 'show_if_not' => array('link_type' => array('url', 'sub_l', 'sub_wp', 'popup_l')), ); $popup_settings = array( 'preview' => true, 'show_if' => array('link_type' => 'popup_l'), 'show_if_custom' => array('link_type' => array('popup_c', 'popup_l')), 'toggle_slug' => 'item_link', 'advanced_slug' => 'item_link' ); $fields = array_merge( $fields, $helper->get_font_fields( 'body_ul', 'body_ol', 'body_quote', 'body'), $helper->get_popup_fields($popup_settings), $helper->get_custom_content_fields($cc_settings), $this->get_sub_fields(), $helper->get_url_fields( 'item_link', array( 'url', 'sub_c', 'sub_l', 'sub_wp' ), array( 'bookmark', 'external', 'nofollow', 'noreferrer', 'noopener', 'sponsored' )), $helper->get_effect_fields( 'effects', array('link_type' => array('popup_c', 'popup_l', 'sub_c', 'sub_l', 'sub_wp'))), $this->get_cart_fields(), array( 'active_url' => array( 'label' => esc_html__( 'Enable Active Page', 'dd_builder' ), 'description' => esc_html__( 'Here you can choose whether or not this menu item should be on hover state when the link URL matches the page URL', 'dd_builder' ), 'type' => 'yes_no_button', 'options' => $helper->get_yes_no_button_options(), 'default' => 'off', 'toggle_slug' => 'item_link', ), ) ); return $fields; } public function render( $attrs, $content, $render_slug ) { $helper = DonDiviBuilderHelper::get(); $multi_view = et_pb_multi_view_options( $this ); $popup_link_type = in_array( $this->props['link_type'], array( 'popup_c', 'popup_l' )); $sub_link_type = in_array( $this->props['link_type'], array( 'sub_c', 'sub_l', 'sub_wp' )); if ( $popup_link_type ) { wp_enqueue_script( 'ddb-popup' ); } $item_content_inner = ''; if ($this->props['item_content'] === 'text') { if ($this->props['text_icon_image'] !== 'none') { $this->generate_styles( array( 'base_attr_name' => 'inner_content_gap', 'selector' => '%%order_class%% .ddb-item-content-inner', 'css_property' => 'gap', 'render_slug' => $render_slug, ) ); $this->generate_styles( array( 'base_attr_name' => 'text_icon_position', 'selector' => '%%order_class%% .ddb-item-content-inner', 'css_property' => 'flex-direction', 'render_slug' => $render_slug, ) ); } if ($this->props['text_icon_image'] === 'icon') { $item_content_inner .= $helper->render_icon( array( 'module' => $this, 'icon_attr' => 'text_font_icon', 'color_attr' => 'text_icon_color', 'size_attr' => 'text_icon_size', 'selector' => '%%order_class%% .ddb-text-icon', 'hover_selector' => '%%order_class%% .ddb-item:hover .ddb-text-icon, %%order_class%% .ddb-item.active .ddb-text-icon', 'content_hover' => '%%order_class%% .ddb-text-icon.hover, %%order_class%% .ddb-text-icon.active', 'attrs' => array( 'class' => 'ddb-text-icon' ), 'custom' => true ) ); } else if ($this->props['text_icon_image'] === 'image') { $item_content_inner .= $helper->render_image( array( 'module' => $this, 'img_attr' => 'text_image' , 'attrs' => array( 'class' => 'ddb-text-image' ), 'custom' => true ) ); $this->generate_styles( array( 'base_attr_name' => 'text_image_width', 'selector' => '%%order_class%% .ddb-text-image', 'css_property' => 'width', 'render_slug' => $render_slug, ) ); } $item_content_inner .= $helper->render_text( array( 'module' => $this, 'text_attr' => 'title', 'attrs' => array('class' => 'ddb-text'), 'custom' => true ) ); } else if ($this->props['item_content'] === 'icon') { $item_content_inner = $helper->render_icon( array( 'module' => $this, 'icon_attr' => 'item_font_icon', 'color_attr' => 'item_icon_color', 'size_attr' => 'item_icon_width', 'selector' => '%%order_class%% .ddb-icon', 'hover_selector'=> '%%order_class%% .ddb-item:hover .ddb-icon, %%order_class%% .ddb-item.active .ddb-icon', 'content_hover' => '%%order_class%% .ddb-icon.hover, %%order_class%% .ddb-icon.active', 'custom' => true ) ); $item_content_inner .= apply_filters('ddb_cart_output', $this->render_cart_quantity(), $this->props); } else { $item_content_inner = $item_content_inner = $helper->render_image( array( 'module' => $this, 'img_attr' => 'item_image', 'alt_attr' => 'item_alt', 'default_image' => ET_BUILDER_PLACEHOLDER_LANDSCAPE_IMAGE_DATA, 'custom' => true ) ); $this->generate_styles( array( 'base_attr_name' => 'item_image_width', 'selector' => '%%order_class%% .ddb-item-content-inner > img', 'css_property' => 'width', 'render_slug' => $render_slug, ) ); } $item_content = $multi_view->render_element( array( 'tag' => 'div', 'content' => $item_content_inner, 'attrs' => array('class' => 'ddb-item-content-inner ddb-rel ddb-f ddb-f-c'), ) ); if ( $sub_link_type && $this->props['use_toggle_icon'] === 'on' ) $item_content .= $helper->render_icon( array( 'module' => $this, 'icon_attr' => 'toggle_font_icon', 'color_attr' => 'toggle_icon_color', 'size_attr' => 'toggle_icon_width', 'attrs' => array( 'class' => 'ddb-toggle-icon ddb-click' ), 'selector' => '%%order_class%% .ddb-toggle-icon', 'hover_selector' => '%%order_class%% .ddb-item:hover .ddb-toggle-icon, %%order_class%% .ddb-item.active .ddb-toggle-icon', 'content_hover' => '%%order_class%% .ddb-toggle-icon.active', 'custom' => true ) ); $item = $multi_view->render_element( array( 'tag' => 'div', 'content' => $item_content, 'attrs' => array('class' => 'ddb-item-content ddb-f ddb-f-c ddb-w-100'), ) ); $item_attrs = array('class' => 'ddb-item ddb-f ddb-f-c ddb-p-s ddb-dark ddb-bss'); $item_attrs['href'] = $this->get_url(); // dondivi_menu_item_url if ( $this->props['url_new_window'] === 'on' ) $item_attrs['target']= '_blank'; $popup_output = ''; if ($popup_link_type) { $popup_output = $helper->render_popup( array( 'module' => $this, 'slug' => 'menu-item', 'layout_popup' => $this->props['link_type'] === 'popup_l', 'attrs' => array( 'data-element-class' => $this->get_module_order_class( $render_slug ) . ' .ddb-item' ), 'item_popup' => true, )); } $sub_output = ''; if ($sub_link_type) { $sub_output = $this->render_sub(); if ( $sub_output ) { $item_attrs['class'] .= ' ddb-sub'; $helper->set_effect_attrs( $item_attrs, $this->props ); if ( $this->props['sub_open_url'] === 'on' && $this->props['url'] !== '' ) $item_attrs['class'] .= ' ddb-open-url'; } } if ($this->props['active_url'] === 'on') $item_attrs['class'] .= ' ddb-active-url'; $item_link = $multi_view->render_element( array( 'tag' => 'a', 'content' => $item, 'attrs' => $item_attrs, 'classes' => array( 'ddb-h-hover' => array('link_type' => array( 'sub_c', 'sub_l', 'sub_wp' ), 'sub_display' => 'hover'), 'ddb-h-click' => array('link_type' => array( 'sub_c', 'sub_l', 'sub_wp' ), 'sub_display' => 'click'), 'ddb-toggle' => array('link_type' => array( 'sub_c', 'sub_l', 'sub_wp' ), 'sub_display' => 'toggle'), ), ) ); $item_wrapper_classes = array('ddb-item-wrapper'); if ($sub_output && $this->props['sub_alignment'] === 'justified') $item_wrapper_classes[]= 'ddb-sub-fw'; return sprintf( '
%2$s. %3$s.
', esc_url( admin_url( 'nav-menus.php' ) ), esc_html__( 'Select a menu that should be used as the dropdown menu', 'et_builder' ), esc_html__( 'Click here to create a new menu', 'et_builder' ) ), 'type' => 'select', 'options' => et_builder_get_nav_menus_options(), 'default' => 'none', 'show_if' => array('link_type' => 'sub_wp'), 'toggle_slug' => 'item_link', 'computed_affects' => array( '__wp_menu', ), ), '__wp_menu' => array( 'type' => 'computed', 'computed_callback' => array( 'DonDiviBuilderHelper', 'render_wp_nav_menu' ), 'computed_depends_on' => array( 'wp_accordion', 'wp_menu_id', 'wp_collapse', 'wp_menu_icon', ), 'computed_minimum' => array( 'wp_menu_id', ), ), '__sub_element' => array( 'type' => 'computed', 'computed_callback' => array( 'DonDiviBuilderHelper', 'render_divi_layout' ), 'computed_depends_on' => array( 'layout_id', ), 'computed_minimum' => array( 'layout_id', ), ), 'sub_display' => array( 'label' => esc_html__( 'Display Behavior', 'dd_builder' ), 'type' => 'select', 'options' => array( 'hover' => esc_html__( 'Hover', 'et_builder' ), 'click' => esc_html__( 'Click', 'et_builder' ), 'toggle' => esc_html__( 'Toggle', 'et_builder' ), ), 'default' => 'hover', 'show_if' => array('link_type' => array('sub_c', 'sub_l', 'sub_wp')), 'mobile_options' => true, 'toggle_slug' => 'item_link', ), 'sub_width' => array( 'label' => esc_html__( 'Width', 'et_builder' ), 'description' => esc_html__( 'You can set a width here. If using Divi Layouts, remember that you can set the width in the Layout itself.', 'dd_builder' ), 'type' => 'range', 'range_settings' => array( 'max' => 500, 'step' => 1, ), 'show_if' => array('link_type' => array('sub_c', 'sub_l', 'sub_wp')), 'allowed_values' => et_builder_get_acceptable_css_string_values( 'width' ), 'default_unit' => 'px', 'validate_unit' => true, 'mobile_options' => true, 'toggle_slug' => 'item_link', ), 'sub_offset' => array( 'label' => esc_html__( 'Offset', 'dd_builder' ), 'type' => 'range', 'default' => '15px', 'show_if' => array('link_type' => array('sub_c', 'sub_l', 'sub_wp')), 'fixed_unit' => 'px', 'mobile_options'=> true, 'toggle_slug' => 'item_link' ), 'wp_collapse' => array( 'label' => esc_html__( 'Collapsible', 'dd_builder' ), 'type' => 'yes_no_button', 'options' => $helper->get_yes_no_button_options(), 'default' => 'off', 'show_if' => array('link_type' => 'sub_wp'), 'toggle_slug' => 'item_link', 'computed_affects' => array( '__wp_menu', ), ), 'wp_menu_icon' => array( 'label' => esc_html__( 'Collapse Icon', 'dd_builder' ), 'type' => 'select_icon', 'class' => array( 'et-pb-font-icon' ), 'default' => 'C||divi||400', 'show_if' => array('link_type' => 'sub_wp', 'wp_collapse' => 'on'), 'toggle_slug' => 'item_link', 'hover' => 'tabs', 'computed_affects' => array( '__wp_menu', ), ), 'wp_accordion' => array( 'label' => esc_html__( 'Accordion', 'dd_builder' ), 'type' => 'yes_no_button', 'options' => $helper->get_yes_no_button_options(), 'default' => 'off', 'show_if' => array('link_type' => 'sub_wp', 'wp_collapse' => 'on'), 'toggle_slug' => 'item_link', 'computed_affects' => array( '__wp_menu', ), ), 'sub_arrow' => array( 'label' => esc_html__( 'Show Arrow', 'dd_builder' ), 'type' => 'yes_no_button', 'options' => $helper->get_yes_no_button_options(), 'default' => 'off', 'mobile_options'=> true, 'show_if' => array('link_type' => array('sub_c', 'sub_l', 'sub_wp')), 'toggle_slug' => 'item_link', ), 'arrow_offset' => array( 'label' => esc_html__( 'Arrow Offset', 'dd_builder' ), 'type' => 'range', 'default_unit' => '%', 'default' => '50%', 'mobile_options' => true, 'show_if' => array( 'link_type' => array('sub_c', 'sub_l', 'sub_wp'), 'sub_arrow' => 'on' ), 'toggle_slug' => 'item_link', ), 'sub_open_url' => array( 'label' => esc_html__( 'Open URL', 'dd_builder' ), 'description' => esc_html__( 'If enabled, the destination URL introduced in the URL field will be opened on Menu Item Click', 'dd_builder' ), 'type' => 'yes_no_button', 'options' => $helper->get_yes_no_button_options(), 'default' => 'off', 'show_if' => array('link_type' => array('sub_c', 'sub_l', 'sub_wp') /*, 'url' => '__not_empty' */), 'toggle_slug' => 'item_link', ), 'use_toggle_icon' => array( 'label' => esc_html__( 'Use Toggle Icon', 'dd_builder' ), 'description' => esc_html__( 'If enabled, the destination URL introduced in the URL field will be opened on Menu Item Click', 'dd_builder' ), 'type' => 'yes_no_button', 'options' => $helper->get_yes_no_button_options(), 'default' => 'off', 'show_if' => array('link_type' => array('sub_c', 'sub_l', 'sub_wp') /*, 'url' => '__not_empty' */), 'toggle_slug' => 'item_link', ), 'toggle_font_icon' => array( 'label' => esc_html__( 'Toggle Icon', 'et_builder' ), 'type' => 'select_icon', 'class' => array( 'et-pb-font-icon' ), 'default' => '3||divi||400', 'show_if' => array('link_type' => array('sub_c', 'sub_l', 'sub_wp'), 'use_toggle_icon' => 'on'), 'mobile_options' => true, 'hover' => 'tabs', 'toggle_slug' => 'item_link', ), 'toggle_icon_color' => array( 'label' => sprintf( '%1$s %2$s', esc_html__( 'Toggle Icon', 'et_builder' ), et_builder_i18n( 'Color' ) ), 'description' => esc_html__( 'Here you can define a custom color for your icon.', 'et_builder' ), 'type' => 'color-alpha', 'show_if' => array('link_type' => array('sub_c', 'sub_l', 'sub_wp'), 'use_toggle_icon' => 'on'), 'hover' => 'tabs', 'mobile_options' => true, 'sticky' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'toggle_icon', ), 'toggle_icon_width' => array( 'label' => sprintf( '%1$s %2$s', esc_html__( 'Toggle Icon', 'et_builder' ), esc_html__( 'Width', 'et_builder' ) ), 'description' => esc_html__( 'Here you can choose icon width.', 'et_builder' ), 'default' => '24px', 'type' => 'range', 'default_unit' => 'px', 'allowed_units' => array( '%', 'em', 'rem', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'ex', 'vh', 'vw' ), 'show_if' => array( 'link_type' => array('sub_c', 'sub_l', 'sub_wp'), 'use_toggle_icon' => 'on'/*'url' => '__not_empty'*/ ), 'mobile_options' => true, 'sticky' => true, 'hover' => 'tabs', 'tab_slug' => 'advanced', 'toggle_slug' => 'toggle_icon' ), 'sub_alignment' => array( 'label' => esc_html__( 'Alignment', 'et_builder' ), 'type' => 'text_align', 'options' => et_builder_get_text_orientation_options(), 'options_icon' => 'module_align', 'default' => 'center', 'show_if' => array( 'link_type' => array('sub_c', 'sub_l', 'sub_wp') ), 'tab_slug' => 'advanced', 'toggle_slug' => 'item_link', ), 'sub_background_color' => array( 'label' => esc_html__( 'Background Color', 'et_builder' ), 'type' => 'color-alpha', 'show_if' => array( 'link_type' => array('sub_c', 'sub_l', 'sub_wp') ), 'default' => '#F1F5F9', 'hover' => 'tabs', 'sticky' => true, 'mobile_options' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'item_link', ), 'wp_background_color' => array( 'label' => esc_html__( 'Menu Item Background', 'dd_builder' ), 'description' => esc_html__( 'Here you can define a custom color for the menu items.', 'dd_builder' ), 'type' => 'color-alpha', 'show_if' => array('link_type' => 'sub_wp'), 'hover' => 'tabs', 'sticky' => true, 'mobile_options' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'wp_menu', ), 'arrow_color' => array( 'label' => sprintf('%1$s %2$s', esc_html__( 'Arrow', 'dd_builder' ), et_builder_i18n( 'Color' ) ), 'type' => 'color-alpha', 'default' => '#F1F5F9', 'mobile_options' => true, 'sticky' => true, 'show_if' => array('link_type' => array('sub_c', 'sub_l', 'sub_wp'), 'sub_arrow' => 'on'), 'tab_slug' => 'advanced', 'toggle_slug' => 'item_link', ), 'arrow_width' => array( 'label' => sprintf('%1$s %2$s', esc_html__( 'Arrow', 'dd_builder' ), esc_html__( 'Width', 'et_builder' ) ), 'default' => '15px', 'type' => 'range', 'mobile_options' => true, 'default_unit' => 'px', 'fixed_unit' => 'px', 'show_if' => array('link_type' => array('sub_c', 'sub_l', 'sub_wp'), 'sub_arrow' => 'on'), 'sticky' => true, 'tab_slug' => 'advanced', 'toggle_slug' => 'item_link' ), ); } private function get_sub_pos($hali) { $css = 'position: absolute;'; if ($hali !== 'justified') { $css .= 'min-width:100%;'; $css .= $hali === 'right' ? 'right:0;' : ($hali === 'left' ? 'left:0;' : 'left:50%;transform:translateX(-50%);'); } return $css; } private function get_sub_content_pos($hali) { $css = ''; if ($hali === 'justified') $css .= 'width:100%;'; $css .= $hali === 'right' ? 'margin-left:auto;' : ($hali === 'left' ? 'margin-right:auto;' : 'margin-left:auto;margin-right:auto;'); return $css; } private function get_url() { $url = '#'; if ( $this->is_cart() && $this->props['cart_provider'] === 'wc' && class_exists( 'woocommerce' ) && WC()->cart ) $url = function_exists( 'wc_get_cart_url' ) ? wc_get_cart_url() : WC()->cart->get_cart_url(); else if ( $this->is_cart() && function_exists( 'edd_get_checkout_uri' ) ) $url = edd_get_checkout_uri(); else if ( !empty( $this->props['url']) ) $url = esc_url( $this->props['url'] ); return $url; } private function is_cart() { return isset($this->props['is_cart']) && $this->props['is_cart'] === 'on'; } private function render_cart_quantity(){ $cart_info = ''; if ( !$this->is_cart()) return $cart_info; if ( $this->props['cart_provider'] === 'wc' && !( class_exists( 'woocommerce' ) && WC()->cart) ) return $cart_info; if ( $this->props['cart_provider'] === 'edd' && !function_exists('edd_get_cart_quantity') ) return $cart_info; if ($this->props['cart_quantity'] === 'on') { $cart_quantity = $this->props['cart_provider'] === 'wc' ? WC()->cart->get_cart_contents_count() : edd_get_cart_quantity(); if ( $this->props['cart_items_empty'] === 'off' && $cart_quantity === 0 ) return $cart_info; $cart_classes = array('ddb-cart-info ddb-light ddb-f ddb-f-cc ddb-abs ddb-tr'); $cart_classes[]= $this->props['cart_provider'] === 'wc' ? 'ddb-cart-count' : 'edd-cart-quantity'; $cart_info = sprintf('%1$s', $cart_quantity, implode( ' ', $cart_classes)); $this->generate_styles( array( 'base_attr_name' => 'cart_background_color', 'selector' => '%%order_class%% .ddb-cart-info', 'css_property' => 'background-color', 'render_slug' => $this->slug, ) ); } return $cart_info; } private function render_sub() { $helper = DonDiviBuilderHelper::get(); $multi_view = et_pb_multi_view_options( $this ); $sub = ''; if ($this->props['link_type'] === 'sub_c') { $sub = sprintf('', $helper->render_custom_content( $this, array( 'slug' => 'menu-item') ) ); } else if ($this->props['link_type'] === 'sub_l') $sub = $helper->render_divi_layout( array('internal' => false, 'layout_id' => $this->props['layout_id']) ); else { $wp_args = array( 'module_instance' => $this, 'frontend' => true, 'wp_accordion' => $this->props['wp_accordion'], 'wp_collapse' => $this->props['wp_collapse'], 'wp_menu_icon' => $this->props['wp_menu_icon'], 'wp_menu_id' => $this->props['wp_menu_id'], ); $sub = $helper->render_wp_nav_menu($wp_args); } if ($sub) { $sub = $multi_view->render_element( array( 'tag' => 'div', 'content' => $sub, 'attrs' => array('class' => 'ddb-item-sub ddb-rel ddb-none'), 'classes' => array( 'ddb-arrow' => array('link_type' => array( 'sub_c', 'sub_l', 'sub_wp' ), 'sub_arrow' => 'on'), ), ) ); $sub_display = et_pb_responsive_options()->get_property_values($this->props, 'sub_display', $this->props['sub_display'], true); foreach ( et_pb_responsive_options()->get_modes() as $device ) { if ($sub_display[$device] !== 'toggle') { $helper->set_style($this->slug, '%%order_class%% .ddb-item-sub', $this->get_sub_pos($this->props['sub_alignment']), substr( $device, 0, 1 )); } } $helper->set_style($this->slug, '%%order_class%% .ddb-item-sub > *', $this->get_sub_content_pos($this->props['sub_alignment'])); $this->generate_styles( array( 'base_attr_name' => 'sub_offset', 'selector' => '%%order_class%% .ddb-item-sub', 'css_property' => 'padding-top', 'render_slug' => $this->slug, ) ); $this->generate_styles( array( 'base_attr_name' => 'sub_width', 'selector' => '%%order_class%% .ddb-item-sub > *', 'css_property' => 'width', 'render_slug' => $this->slug, ) ); $this->generate_styles( array( 'base_attr_name' => 'sub_background_color', 'selector' => '%%order_class%% .ddb-item-sub > *', 'css_property' => 'background-color', 'render_slug' => $this->slug, ) ); if ( $multi_view->has_value( 'sub_arrow', 'on' ) ) { $selector = '%%order_class%% .ddb-item.ddb-item-open + .ddb-item-sub:after, %%order_class%% .ddb-sub-hover .ddb-item-sub:after'; $this->generate_styles( array( 'base_attr_name' => 'sub_offset', 'selector' => $selector, 'css_property' => '--ddb-sub-offset', 'render_slug' => $this->slug, ) ); $this->generate_styles( array( 'base_attr_name' => 'arrow_color', 'selector' => $selector, 'css_property' => 'border-bottom-color', 'render_slug' => $this->slug, ) ); $this->generate_styles( array( 'base_attr_name' => 'arrow_width', 'selector' => $selector, 'css_property' => 'border-width', 'render_slug' => $this->slug, ) ); $this->generate_styles( array( 'base_attr_name' => 'arrow_offset', 'selector' => $selector, 'css_property' => 'left', 'render_slug' => $this->slug, ) ); } $this->generate_styles( array( 'base_attr_name' => 'content_gap', 'selector' => '%%order_class%% .ddb-item-content', 'css_property' => 'gap', 'render_slug' => $this->slug, ) ); if ($this->props['link_type'] === 'sub_wp') { $helper->set_style( $this->slug, '%%order_class%% .ddb-item-wrapper .ddb-item-sub > ul', 'padding: 15px;'); $helper->set_style( $this->slug, '%%order_class%% .ddb-item-sub ul', 'list-style:none; padding: 0;'); $helper->set_style( $this->slug, '%%order_class%% .ddb-item-sub ul a', 'color:inherit;line-height:1.3em;'); $this->generate_styles( array( 'base_attr_name' => 'wp_background_color', 'selector' => '%%order_class%% .ddb-item-wrapper .ddb-item-sub .ddb-wp-item', 'hover_selector' => '%%order_class%% .ddb-item-wrapper .ddb-item-sub .ddb-wp-item:hover, %%order_class%% .ddb-item-wrapper .ddb-item-sub .ddb-wp-item.active', 'css_property' => 'background-color', 'render_slug' => $this->slug, 'type' => 'color', ) ); $helper->set_style( $this->slug, '%%order_class%% .ddb-item-sub ul ul a', 'padding-left: 20px;'); if ($this->props['wp_collapse'] === 'on') { $helper->set_style( $this->slug, '%%order_class%% .ddb-collapsible ul, %%order_class%% .menu-item:not(.ddb-collapsible) span.ddb-collapse', 'display:none;' ); $helper->set_style( $this->slug, '%%order_class%% .ddb-item-sub span.ddb-collapse', 'font-size:inherit;'); } } } return $sub; } } new DDBUILDER_Menu_Item_Module;