<?php 
/*****************************************************************************************************************************************************
******************************************************************************************************************************************************
 
																	Register Widget Product
 
*/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
add_action( 'widgets_init', 'reza_register_widget_menu' );
 function reza_register_widget_menu() {
    register_widget( 'reza_widget_menu' );
}

class reza_widget_menu extends WP_Widget {
 	function __construct() {
		parent::__construct(
			'reza_menu',
			  __('rabonews','reza').' - '.  __('فهرست', 'reza') 
		);
	}
	public function option(){
		$option[]= array( 
		"name"			=> esc_html__('Title Box','reza'),
 		"id"			=> "title",
 		"default"		=> esc_html__('Title Box','reza'),
 		"type"			=> "text",
 		   
	);
					
 	$option[]= array( 
		"name"			=>  'انتخابات فهرست' ,
 		"id"			=> "menu",
  		"type"			=> "select",
 		"options"		=>  reza_category_array_options('menu'),						
 	);	
	
	$option[]= array( 
		"name"			=> 'حداقل تعداد نمایش فهرست',
 		"id"			=> "number",
 		"default"		=> 10,
  		"type"			=> "number",
 		  
	);
 
  
 	
		return $option;
    }	
	
   /********** Update the widget info from the admin panel *******/
 	public function update( $new_instance, $old_instance ) {
		$instance = $old_instance;
  		return	reza_widget_options_save( $new_instance, $old_instance,$this->option() );
 	}
 
	/********** Display the widget update form *******/
 	public function form( $instance ) { 
		$defaults = array( 'number' => '5', 'image_size' => 'full' );
		$instance = wp_parse_args( (array) $instance, $defaults );
 
		reza_widget_options($instance,$this->id_base,$this->number,$this->option());
  
 	}	
    /**********  The widget For Display *******/
 	public function widget( $args, $instance ) {
		extract( $args );
 		$title = apply_filters( 'widget_title', $instance[ 'title' ] );
 		$tecnoshop_data =$instance;
 		$count = 0;
		 $args=array();
	
 		$args['key'] = 'widget_menu';
 
		$args['option'] =array(
 			'title' => !empty( $instance['title'] ) ? $instance['title'] : '',
 			'number' => !empty( $instance['number'] ) ? $instance['number'] : '',
 			'menu' => !empty( $instance['menu'] ) ? $instance['menu'] : '',
 			 
		) ; 
 
		global $smof_data; 
		?>
 
		<div id="<?php echo esc_attr($widget_id) ?>" class="rd-element-menu rd-widget-post rd-element-item">
 			 <?php 	echo reza_menu_config($args, true);?>
		</div>
        
        
	<?php 
	
	}

    /********** Update the widget info from the admin panel *******/
 
}
 ?>