<?php
add_action( 'widgets_init', 'wp_posts_box_13_widget' );
function wp_posts_box_13_widget() {
	register_widget( 'wp_posts_box_13_widget' );
}

class wp_posts_box_13_widget extends WP_Widget {

	public function __construct(){
		$widget_ops = array( 'classname' => 'wp_posts_box_13_widget','description' => 'سایدبار مدیا'  );
		$control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => 'wp_posts_box_13_widget' );
		parent::__construct( 'wp_posts_box_13_widget',''. __( 'News - گالری عکس و فیلم ' , 'wp'), $widget_ops, $control_ops );
	}

	
	function widget( $args, $instance ) {
		extract( $args );	
 ?>
    <section class="media-section">
        <div class="container">
            <div class="row">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-md-8">	
            <section id="carousel14" class="box top showcase slider has-desc has-kicker has-carousel full-image no-indicators has-carousel" style="" data-conf="{&quot;items&quot;:1,&quot;auto&quot;:7000,&quot;fx&quot;:false,&quot;autoHeight&quot;:false,&quot;controls&quot;:true,&quot;paging&quot;:false,&quot;pagingHeader&quot;:false}">
                <header>
                    <h2 style=""><a><i class="fa fa-camera-retro" aria-hidden="true" style="font-size:17px"></i> گزارش تصویری</a>
                    </h2>
                </header>
                <div>
                    <ul>		
<?php
$wp_query = new WP_Query(array('post_type' => 'gallery','posts_per_page'=> '5' ));
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
 <li class="photo">
                  <figure><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
                   <?php if(has_post_thumbnail()){?>
				   <img src="<?php the_post_thumbnail_url('img-755'); ?>" alt="<?php the_title(); ?>"> <?php }else{ ?>
                   <img src="<?php bloginfo("template_url"); ?>/img/225.png">
                    <?php } ?>
                    </a></figure>
                 <div class="desc">
                 <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                  </div>
                  </li>	 
<?php
endwhile;
wp_reset_query();
?>
 </ul>
</div>               
</section>
</div>
			
<div class="col-xs-12 col-md-4">
            <section id="box113" class="box media-section vertical videos lazy-player">
                <header>
                    <h2 style=""><a><i class="fa fa-video-camera" aria-hidden="true" style="font-size:17px"></i> فیلم</a></h2>
                </header>
                <div>
                    <ul>			
<?php
$wp_query = new WP_Query(array('post_type' => 'media','posts_per_page'=> '2' ));
while ($wp_query->have_posts()) : $wp_query->the_post();
?>

                      <li class="video">
                     <figure><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">     
					 <?php if(has_post_thumbnail()){?>
				   <img src="<?php the_post_thumbnail_url('img-410'); ?>" alt="<?php the_title(); ?>"> <?php }else{ ?>
                   <img src="<?php bloginfo("template_url"); ?>/img/225.png">
                    <?php } ?>
					</a></figure>
                   <div class="desc"><h3><a href="<?php the_permalink(); ?>" title=" <?php the_title(); ?>"><?php the_title(); ?></a></h3></div>
                    </li>
<?php
endwhile;
wp_reset_query();
?>
</ul></div></section></div></div></div></div></div></section>

	<?php 
	}

	function update( $new_instance, $old_instance ) {
		$instance              = $old_instance;
		return $instance;
	}

	function form( $instance ) {

		?>
		<p>
			<?php $icon_url = esc_url( get_template_directory_uri().( '/img/box/13.png' ) ); ?>
			<center><img src="<?php echo $icon_url; ?>" alt="" /></center>
		</p>
        <p><em style="color:#0073aa;"><?php echo 'توجه : '; ?></em></p>
		<p><em style="color:#0085ba;"><?php echo 'این تب فقط آخرین گالری عکس و فیلم را نمایش می دهد.'; ?></em></p>
	

		<?php
	
	}
}
?>