prefix = Easy_get_prefix(); /* Set the widget textdomain. */ $this->textdomain = Easy_get_textdomain(); /* Set up the widget options. */ $widget_options = array( 'classname' => 'nav-menu', 'description' => esc_html__( 'An advanced widget that gives you total control over the output of your menus.', $this->textdomain ) ); /* Set up the widget control options. */ $control_options = array( 'width' => 525, 'height' => 350, 'id_base' => "{$this->prefix}-nav-menu" ); /* Create the widget. */ $this->WP_Widget( "{$this->prefix}-nav-menu", esc_attr__( 'Navigation Menu', $this->textdomain ), $widget_options, $control_options ); } /** * Outputs the widget based on the arguments input through the widget controls. * @since 0.8.0 */ function widget( $args, $instance ) { extract( $args ); /* Set up the arguments for the wp_nav_menu() function. */ $args = array( 'menu' => $instance['menu'], 'container' => $instance['container'], 'container_id' => $instance['container_id'], 'container_class' => $instance['container_class'], 'menu_id' => $instance['menu_id'], 'menu_class' => $instance['menu_class'], 'link_before' => $instance['link_before'], 'link_after' => $instance['link_after'], 'before' => $instance['before'], 'after' => $instance['after'], 'depth' => intval( $instance['depth'] ), 'fallback_cb' => $instance['fallback_cb'], 'walker' => $instance['walker'], 'echo' => false ); /* Output the theme's widget wrapper. */ echo $before_widget; /* If a title was input by the user, display it. */ if ( !empty( $instance['title'] ) ) echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title; /* Output the nav menu. */ echo str_replace( array( "\r", "\n", "\t" ), '', wp_nav_menu( $args ) ); /* Close the theme's widget wrapper. */ echo $after_widget; } /** * Updates the widget control options for the particular instance of the widget. * @since 0.8.0 */ function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance = $new_instance; $instance['title'] = strip_tags( $new_instance['title'] ); $instance['depth'] = strip_tags( $new_instance['depth'] ); $instance['container_id'] = strip_tags( $new_instance['container_id'] ); $instance['container_class'] = strip_tags( $new_instance['container_class'] ); $instance['menu_id'] = strip_tags( $new_instance['menu_id'] ); $instance['menu_class'] = strip_tags( $new_instance['menu_class'] ); $instance['fallback_cb'] = strip_tags( $new_instance['fallback_cb'] ); $instance['walker'] = strip_tags( $new_instance['walker'] ); return $instance; } /** * Displays the widget control options in the Widgets admin screen. * @since 0.8.0 */ function form( $instance ) { /* Set up the default form values. */ $defaults = array( 'title' => esc_attr__( 'Navigation', $this->textdomain ), 'menu' => '', 'container' => 'div', 'container_id' => '', 'container_class' => '', 'menu_id' => '', 'menu_class' => 'nav-menu', 'depth' => 0, 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'fallback_cb' => 'wp_page_menu', 'walker' => '' ); /* Merge the user-selected arguments with the defaults. */ $instance = wp_parse_args( (array) $instance, $defaults ); $container = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) ); ?>