0
class p30code_top_categories_widget extends WP_Widget {

    public function __construct() {
        $widget_ops = array( 
            'classname' => 'p30code_top_categories_widget',
            'description' => '',
        );
        parent::__construct( 'p30code_top_categories_widget', '', $widget_ops );
    }

    public function widget( $instance ) {


?>


<div class="box">
    <div class="title">
        <h5 class="title-text text-orange"> <span class="text-danger"></span><span class="img-icon video-options"></span></h5>
    </div>
    <?php wp_nav_menu(array('menu' => $top_categories_menu_select, 'depth' => 5, 'container' => 'ul', 'menu_class' => 'genre-list inline-list two-col', 'echo' => false, 'fallback_cb' => '__return_false')); ?>
</div>

    <?php }


    public function form( $instance ) {


        $top_categories_menus = wp_get_nav_menus( array( 'orderby' => 'name' ) );

        if (!$top_categories_menus) {
            echo '<div class="widget-body"><p>'. sprintf( __('No menus have been created yet. <a href="%s">Create some</a>.'), admin_url('nav-menus.php') ) .'</p></div>';
            return;
        }




    ?>


<div class="widget-body">
    <p>
        <label for="<?php echo $this->get_field_id('top_categories_select'); ?>"><?php _e('select'); ?>
            <select class="widefat" id="<?php echo $this->get_field_id('top_categories_select'); ?>" name="<?php echo $this->get_field_name('top_categories_select'); ?>">
                <?php foreach ( $top_categories_menus as $top_categories_menu ) { echo '<option value="' . $top_categories_menu->term_id . '"' . selected( $top_categories_select, $top_categories_menu->term_id, false ) . '>'. esc_html( $top_categories_menu->name ) . '</option>'; } ?>
            </select>
        </label>
    </p>
</div>


    <?php }

    public function update( $new_instance, $old_instance ) {
        $instance = $old_instance;
        $instance['top_categories_select'] = (!empty($new_instance['top_categories_select']) ? $new_instance['top_categories_select'] : '');
        return $instance;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.