'widget-oceanwp-custom-menu custom-menu-widget', 'description' => esc_html__( 'Displays custom menu.', 'ocean-extra' ), 'customize_selective_refresh' => true, ) ); } /** * Front-end display of widget. * * @see WP_Widget::widget() * @since 1.0.0 * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget( $args, $instance ) { $title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : ''; $nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false; $position = isset( $instance['position'] ) ? $instance['position'] : 'left'; $dropdown = isset( $instance['dropdown'] ) ? $instance['dropdown'] : 'hover'; $target = isset( $instance['target'] ) ? $instance['target'] : 'icon'; $nav_padding = isset( $instance['nav_padding'] ) ? $instance['nav_padding'] : ''; $nav_link_color = isset( $instance['nav_link_color'] ) ? $instance['nav_link_color'] : ''; $nav_link_hover_color = isset( $instance['nav_link_hover_color'] ) ? $instance['nav_link_hover_color'] : ''; $font_size = isset( $instance['font_size'] ) ? $instance['font_size'] : ''; $line_height = isset( $instance['line_height'] ) ? $instance['line_height'] : ''; $letter_spacing = isset( $instance['letter_spacing'] ) ? $instance['letter_spacing'] : ''; $text_transform = isset( $instance['text_transform'] ) ? $instance['text_transform'] : ''; if ( ! $nav_menu ) { return; } // Before widget WP hook echo $args['before_widget']; // Style if ( $nav_padding && '8px 0' != $nav_padding || $nav_link_color && '#555' != $nav_link_color || $nav_link_hover_color && '#333' != $nav_link_hover_color || $font_size && '13' != $font_size || $line_height && '20' != $line_height || $letter_spacing && '0.6' != $letter_spacing || $text_transform && 'default' != $text_transform ) { echo ''; } // Show widget title if ( $title ) { echo $args['before_title'] . esc_html( $title ) . $args['after_title']; } // Menu classes $menu_classes = array( 'dropdown-menu' ); // Dropdown if ( 'hover' == $dropdown ) { $menu_classes[] = 'sf-menu'; } else if ( 'click' == $dropdown ) { $menu_classes[] = 'click-menu'; } $menu_classes = implode( ' ', $menu_classes ); $nav_menu_args = array( 'menu' => $nav_menu, 'fallback_cb' => false, 'container' => false, 'menu_class' => $menu_classes, 'walker' => new Ocean_Extra_Nav_Walker(), ); // Add classes $classes = array( 'oceanwp-custom-menu', 'clr' ); $classes[] = esc_attr( $this->id ); $classes[] = esc_attr( $position ); $classes[] = 'dropdown-' . esc_attr( $dropdown ); if ( 'click' == $dropdown ) { $classes[] = 'click-' . esc_attr( $target ); } $classes = implode( ' ', $classes ); echo '
'; wp_nav_menu( $nav_menu_args ); echo '
'; // After widget WP hook echo $args['after_widget']; if ( 'click' == $dropdown ) { ?> '', 'nav_menu' => '', 'position' => 'left', 'dropdown' => 'hover', 'target' => 'icon', 'nav_padding' => '', 'nav_link_color' => '#555', 'nav_link_hover_color' => '#333', 'font_size' => '13', 'line_height' => '20', 'letter_spacing' => '0.6', 'text_transform' => 'default', ) ); // Get menus $menus = wp_get_nav_menus(); $nav_menu = isset( $instance['nav_menu'] ) ? $instance['nav_menu'] : ''; // If no menus exists, direct the user to go and create some. ?>