get_widget_slug(), __( 'UberMenu Navigation', 'ubermenu' ), array( 'classname' => $this->get_widget_slug().'-class', 'description' => __( 'Place an UberMenu in a Widget Area. Do NOT place in an [UberMenu] Widget Area.', 'ubermenu' ) ) ); // Refreshing the widget's cached output with each new post add_action( 'save_post', array( $this, 'flush_widget_cache' ) ); add_action( 'deleted_post', array( $this, 'flush_widget_cache' ) ); add_action( 'switch_theme', array( $this, 'flush_widget_cache' ) ); } // end constructor /** * Return the widget slug. * * @since 1.0.0 * * @return Plugin slug variable. */ public function get_widget_slug() { return $this->widget_slug; } /*--------------------------------------------------*/ /* Widget API Functions /*--------------------------------------------------*/ /** * Outputs the content of the widget. * * @param array args The array of form elements * @param array instance The current instance of the widget */ public function widget( $args, $instance ) { extract( $args, EXTR_SKIP ); echo $before_widget; extract( wp_parse_args( (array) $instance , array( //'instance_id' => 'main', 'config_id' => 'main', 'theme_location'=> 0, 'menu_id' => 0, ) ) ); if( $theme_location ){ wp_nav_menu( array( 'theme_location' => $theme_location ) ); } else{ if( $menu_id ){ ubermenu( $config_id , array( 'menu' => $menu_id ) ); } else{ ubermenu( $config_id ); } } echo $after_widget; } // end widget public function flush_widget_cache() { wp_cache_delete( $this->get_widget_slug(), 'widget' ); } /** * Processes the widget's options to be saved. * * @param array new_instance The new instance of values to be generated via the update. * @param array old_instance The previous instance of values before the update. */ public function update( $new_instance, $old_instance ) { $instance = $old_instance; // TODO: Here is where you update your widget's old values with the new, incoming values $instance['config_id'] = isset( $new_instance['config_id'] ) ? $new_instance['config_id'] : 'main'; $instance['theme_location'] = isset( $new_instance['theme_location'] ) ? $new_instance['theme_location'] : 0; $instance['menu_id'] = isset( $new_instance['menu_id'] ) ? $new_instance['menu_id'] : 0; return $instance; } // end widget /** * Generates the administration form for the widget. * * @param array instance The array of keys and values for the widget. */ public function form( $instance ) { extract( wp_parse_args( (array) $instance , array( 'config_id' => 'main', 'theme_location'=> 0, 'menu_id' => 0, ) ) ); echo '

'.__( 'This widget inserts an UberMenu in one of two ways:' , 'ubermenu' ).'

'; //Alternatively, you can set a Theme Location if you do not have a specific menu assigned to this instance, and that menu will be used. $instances = ubermenu_get_menu_instances( true ); ?>
'.__( '1. By Menu Configuration' , 'ubermenu' ).''; echo '

'.__( '(1) Set the UberMenu Configuration to use. The menu set for that Configuration\'s "Default Manual Integration Menu" will be used by default. You can override the menu used by using the Menu setting below.' , 'ubermenu' ).'

'; ?>

'name') ); ?>


'.__( '2. By Theme Location' , 'ubermenu' ).''; echo '

'.__( 'Alternatively, set a Theme Location to just insert a standard menu that you can then activate as an UberMenu.' , 'ubermenu' ).'

'; $theme_locs = get_registered_nav_menus(); ?>


Setting the Theme Location will override the Menu Instance Settings