prefix = framework_get_prefix();
/* Set up the widget options. */
$widget_options = array(
'classname' => 'nav-menu',
'description' => esc_html__( 'Display your site\'s menus.', 'wordsmith' )
);
/* Set up the widget control options. */
$control_options = array(
'width' => 200,
'height' => 350
);
/* Create the widget. */
$this->WP_Widget( "{$this->prefix}-nav-menu", __( 'Navigation Menu', 'wordsmith' ), $widget_options, $control_options );
}
/** Outputs the widget based on the arguments input through the widget controls. */
function widget( $args, $instance ) {
extract( $args );
/* Set the $args for wp_nav_menu() to the $instance array. */
$args = $instance;
/* Overwrite the $echo argument. */
$args['echo'] = false;
/* Overwrite the container_class argument. */
$args['container_class'] = false;
/* Overwrite the items_wrap argument. */
$args['items_wrap'] = '
';
/* 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. */
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'] );
return $instance;
}
/* Displays the widget control options in the Widgets admin screen. */
function form( $instance ) {
/* Set up the default form values. */
$defaults = array(
'title' => esc_attr__( 'Navigation', 'wordsmith' ),
'link_before' => '',
'link_after' => '',
'menu' => '',
'depth' => 0
);
/* Merge the user-selected arguments with the defaults. */
$instance = wp_parse_args( (array) $instance, $defaults );
?>