<?php
   add_action('widgets_init', 'tigu_home_categories_load_widgets');
   function tigu_home_categories_load_widgets()
   {
      register_widget('Tigu_home_categories');
   }
      class Tigu_home_categories extends WP_Widget {
   function Tigu_home_categories()
   {
      $widget_ops = array(
                   'classname' => 'tigu_home_categories',
                   'description' => 'Display two blocks inline - categories with recent posts on Homepage.');
      $control_ops = array(
                    'id_base' => 'tigu_home_categories');
      $this->WP_Widget('tigu_home_categories', 'GAMELEON: Boxed Categories', $widget_ops, $control_ops);
   }
   function widget($args, $instance)
   {
      extract($args);

/* User selected settings. */
      $show_excerpt = isset($instance['show_excerpt']) ? 'true' : 'false';
      $show_big_excerpt = isset($instance['show_big_excerpt']) ? 'true' : 'false';
      $title = $instance['title'];
      $show_aftermore = isset($instance['show_aftermore']) ? 'true' : 'false'; 
      $aftermore = $instance['aftermore'];
      $bigexcerpt = $instance['bigexcerpt'];
      $smallexcerpt = $instance['smallexcerpt'];
      $post_type = 'all';
      $categories = $instance['categories'];
      $posts = $instance['posts'];
      $posts_2 = $instance['posts_2'];
      $images = true;
      $title_2 = $instance['title_2'];
      $post_type_2 = 'all';
      $categories_2 = $instance['categories_2'];
      $images_2 = true;
      $show_plays_counter = isset($instance['show_plays_counter']) ? 'true' : 'false';
      $show_comments_counter = isset($instance['show_comments_counter']) ? 'true' : 'false';
      $show_likes_counter = isset($instance['show_likes_counter']) ? 'true' : 'false';
      $show_footer_box = isset($instance['show_footer_box']) ? 'true' : 'false';
      $show_statistics = isset($instance['show_statistics']) ? 'true' : 'false';
      $show_big_image = isset($instance['show_big_image']) ? 'true' : 'false';
      echo $before_widget;
?>

<!-- START WIDGET -->

<?php
      $post_types = get_post_types();
      unset($post_types['page'], $post_types['attachment'], $post_types['revision'], $post_types['nav_menu_item']);
      if($post_type == 'all') {
      $post_type_array = $post_types;
   } else {
      $post_type_array = $post_type;
   }
?>
<?php if($show_big_image == 'true'): ?>
<div class="block half">
<div class="grids_box">
			<h3><a href="<?php echo get_category_link($categories); ?>"><?php echo $title; ?></a></h3>
				</div>
			<?php
			$recent_posts = new WP_Query(array(
				'showposts' => $posts,
				'cat' => $categories,
			));
			?>
			<?php $counter = 1; while($recent_posts->have_posts()): $recent_posts->the_post(); ?>
			<?php
			if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {
				$icon = '<span class="' . get_post_format($post->ID) . '-icon"></span>';
			} else {
				$icon = '';
			}
			?>
			<?php if($counter == 1): ?>

			<div class="grid-box">
				<?php if($images && (has_post_thumbnail() || is_myarcade_game()) ): ?>
				<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'category-big'); ?>
                <?php if ( empty($image[0]) ) $image[0] = myarcade_featured_image (); ?>
                <div class=<?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>"hover_play_small-wp"<?php else: ?>"hover_play_small"<?php endif; ?>><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>

<img src="<?php echo $image[0]; ?>" width="280" height="131" alt="<?php the_title(); ?>" />

</a><?php echo $icon; ?></div>
                <?php else: ?>
				<div class="grid-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>

<img src="<?php echo get_template_directory_uri(); ?>/images/thumbnail.png" width="280" height="131" alt="<?php the_title(); ?>" />

</a><?php echo $icon; ?></div>
				<?php endif; ?>
				<h2 style="font-size:22px; padding-top:7px; padding-bottom:3px"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><?php the_title(); ?></a></h2>
<span class="block-metas"><?php the_time('F j, Y') ?>, 
<?php if( get_option('tigu_comments_type', 'WordPress') == 'WordPress') : ?>
<?php comments_popup_link(); ?>
<?php else: ?>
<fb:comments-count href="<?php echo get_permalink($post->ID); ?>"></fb:comments-count> <?php _e('COMMENTS', 'Gameleon'); ?>
<?php endif; ?>

</span>
				<?php if($show_big_excerpt == 'true'): ?><p><?php echo get_excerpt($bigexcerpt); ?></p><?php endif; ?>
			</div>
			<?php else: ?>
<div class="showthis">
			<div class="grid-box">
				<?php if($images && (has_post_thumbnail() || is_myarcade_game()) ): ?>
				<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'widget-image-thumb'); ?>
                <?php if ( empty($image[0]) ) $image[0] = myarcade_get_thumbnail_url(); ?>
				<div class="grid-image"><a class=<?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>"hover_play_small-wp"<?php else: ?>"hover_play_small"<?php endif; ?> href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>

<img src="<?php echo $image[0]; ?>" width="76" height="60" alt="<?php the_title(); ?>" />

</a><?php echo $icon; ?></div>
				<?php else: ?>
				<div class="grid-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<img src="<?php echo get_template_directory_uri(); ?>/images/thumbnail-76.png" width="76" height="60" alt="<?php the_title(); ?>" />
</a><?php echo $icon; ?></div>
				<?php endif; ?>
				<h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<?php if(get_option('tigu_shorten_titles') == 'true'): ?>
<?php $shorttitle = substr(the_title('','',FALSE),0,20); ?><?php echo $shorttitle; if (strlen($shorttitle) >19){ echo '&hellip;'; } ?>
<?php else: ?>
<?php the_title(); ?>
<?php endif; ?>


</a></h2>

<?php if($show_excerpt == 'true'): ?><p><?php echo get_excerpt($smallexcerpt); ?></p><?php endif; ?>


<div class="<?php if($show_statistics == 'false'): ?>show-infos<?php endif; ?>">
<div class="clear"></div>
<div class="somepadd block-meta">
<?php if($show_plays_counter == 'true'): ?>
      <?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>
<span class="postviews-wp" title="<?php _e('Views', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?> "><?php _e('Views', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?></span>
<?php else: ?>
<span class="clubs" title="<?php _e('Played', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?> "><?php echo getMostPlayed(get_the_ID()); ?> <?php _e('plays', 'Gameleon'); ?></span>
<?php endif; ?>
<?php endif; ?>

<?php if($show_likes_counter == 'true'): ?>
<span class="minilikes">
<?php _e('Likes', 'Gameleon'); ?>: <?php global $wp_superlike; echo $wp_superlike->show_likes(get_the_ID());?>
</span>
<?php endif; ?>

<?php if($show_comments_counter == 'true'): ?>

<span class="heading-comments">
<?php if( get_option('tigu_comments_type', 'WordPress') == 'WordPress') : ?>   
<?php comments_popup_link('0','1','%'); ?>
<?php else: ?>
<fb:comments-count href="<?php echo get_permalink($post->ID); ?>"></fb:comments-count>
<?php endif; ?>
</span>

<?php endif; ?>
</div>

</div>
</div>
</div>
			<?php endif; ?>
			<?php $counter++; endwhile; ?>
<?php if($show_footer_box == 'true'): ?>
<div class="moregames">
<div class="triangle"></div>
<div class="gamesnumber tooltip" title="<?php echo wt_get_category_count(); ?> <?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>
<?php _e('articles in this category', 'Gameleon'); ?>
<?php else: ?>
<?php _e('games in this category', 'Gameleon'); ?>
<?php endif; ?>">
<?php echo wt_get_category_count(); ?>
</div>
<a href="<?php echo get_category_link($categories); ?>"><?php _e('More', 'Gameleon'); ?><div class="arrow-right"></div> <?php echo $title; ?> <?php if($show_aftermore == 'true'): ?><?php echo ($aftermore); ?><?php endif; ?></a>
</div>
<?php endif; ?>
</div>

		<?php
		$post_types = get_post_types();
		unset($post_types['page'], $post_types['attachment'], $post_types['revision'], $post_types['nav_menu_item']);

		if($post_type_2 == 'all') {
			$post_type_2_array = $post_types;
		} else {
			$post_type_2_array = $post_type;
		}
		?>

		<div class="block half last">
<div class="grids_box">
			<h3><a href="<?php echo get_category_link($categories_2); ?>"><?php echo $title_2; ?></a></h3>
</div>
			<?php
			$recent_posts = new WP_Query(array(
				'showposts' => $posts_2,
				'cat' => $categories_2,
			));
			?>
			<?php $counter = 1; while($recent_posts->have_posts()): $recent_posts->the_post(); ?>
			<?php
			if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {
				$icon = '<span class="' . get_post_format($post->ID) . '-icon"></span>';
			} else {
				$icon = '';
			}
			?>
			<?php if($counter == 1): ?>
			<div class="grid-box">
				<?php if($images && (has_post_thumbnail() || is_myarcade_game()) ): ?>
				<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'category-big'); ?>
                <?php if ( empty($image[0]) ) $image[0] = myarcade_featured_image (); ?>
                <div class=<?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>"hover_play_small-wp"<?php else: ?>"hover_play_small"<?php endif; ?>><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>

<img src="<?php echo $image[0]; ?>" width="280" height="131" alt="<?php the_title(); ?>" />

</a><?php echo $icon; ?></div>
                <?php else: ?>
				<div class="grid-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>

<img src="<?php echo get_template_directory_uri(); ?>/images/thumbnail.png" width="280" height="131" alt="<?php the_title(); ?>" />

</a><?php echo $icon; ?></div>
				<?php endif; ?>
				<h2 style="font-size:22px; padding-top:7px; padding-bottom:3px"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><?php the_title(); ?></a></h2>
				<span class="block-metas"><?php the_time('F j, Y') ?>, 
<?php if( get_option('tigu_comments_type', 'WordPress') == 'WordPress') : ?>
<?php comments_popup_link(); ?>
<?php else: ?>
<fb:comments-count href="<?php echo get_permalink($post->ID); ?>"></fb:comments-count> <?php _e('COMMENTS', 'Gameleon'); ?>
<?php endif; ?>
</span>
				<?php if($show_big_excerpt == 'true'): ?><p><?php echo get_excerpt($bigexcerpt); ?></p><?php endif; ?>
			</div>
			<?php else: ?>
<div class="showthis">
			<div class="grid-box">
				<?php if($images && (has_post_thumbnail() || is_myarcade_game()) ): ?>
				<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'widget-image-thumb'); ?>
                <?php if ( empty($image[0]) ) $image[0] = myarcade_get_thumbnail_url(); ?>
				<div class="grid-image"><a class=<?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>"hover_play_small-wp"<?php else: ?>"hover_play_small"<?php endif; ?> href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>

<img src="<?php echo $image[0]; ?>" width="76" height="60" alt="<?php the_title(); ?>" />

</a><?php echo $icon; ?></div>
                <?php else: ?>
				<div class="grid-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>

<img src="<?php echo get_template_directory_uri(); ?>/images/thumbnail-76.png" width="76" height="60" alt="<?php the_title(); ?>" />

</a><?php echo $icon; ?></div>
				<?php endif; ?>
				<h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<?php if(get_option('tigu_shorten_titles') == 'true'): ?>
<?php $shorttitle = substr(the_title('','',FALSE),0,26); ?><?php echo $shorttitle; if (strlen($shorttitle) >25){ echo '&hellip;'; } ?>
<?php else: ?>
<?php the_title(); ?>
<?php endif; ?>

</a></h2>

<?php if($show_excerpt == 'true'): ?><p><?php echo get_excerpt($smallexcerpt); ?></p><?php endif; ?>
		<div class="<?php if($show_statistics == 'false'): ?>show-infos<?php endif; ?>">
<div class="clear"></div>
<div class="somepadd block-meta">

<?php if($show_plays_counter == 'true'): ?>
      <?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>
<span class="postviews-wp" title="<?php _e('Views', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?> "><?php _e('Views', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?></span>
<?php else: ?>
<span class="clubs" title="<?php _e('Played', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?> "><?php echo getMostPlayed(get_the_ID()); ?> <?php _e('plays', 'Gameleon'); ?></span>
<?php endif; ?>
<?php endif; ?>

<?php if($show_likes_counter == 'true'): ?>
<span class="minilikes">
<?php _e('Likes', 'Gameleon'); ?>: <?php global $wp_superlike; echo $wp_superlike->show_likes(get_the_ID());?>
</span>
<?php endif; ?>

<?php if($show_comments_counter == 'true'): ?>
<span class="heading-comments">
<?php if( get_option('tigu_comments_type', 'WordPress') == 'WordPress') : ?>   
<?php comments_popup_link('0','1','%'); ?>
<?php else: ?>
<fb:comments-count href="<?php echo get_permalink($post->ID); ?>"></fb:comments-count>
<?php endif; ?>
</span>
<?php endif; ?>
</div>
</div>
</div>
</div>
            <?php endif; ?>
			<?php $counter++; endwhile; ?>
<?php if($show_footer_box == 'true'): ?>
<div class="moregames">
<div class="triangle"></div>
<div class="gamesnumber tooltip" title="<?php echo wt_get_category_count(); ?> <?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>
<?php _e('articles in this category', 'Gameleon'); ?>
<?php else: ?>
<?php _e('games in this category', 'Gameleon'); ?>
<?php endif; ?>">
<?php echo wt_get_category_count(); ?>
</div>
<a href="<?php echo get_category_link($categories_2); ?>"><?php _e('More', 'Gameleon'); ?><div class="arrow-right"></div> <?php echo $title_2; ?> <?php if($show_aftermore == 'true'): ?><?php echo ($aftermore); ?><?php endif; ?></a>
</div>
<?php endif; ?>
</div>
<?php else: ?>
      <div class="block half">
<div class="grids_box">
      <h3><a href="<?php echo get_category_link($categories); ?>"><?php echo $title; ?></a></h3>
</div>
<?php
      $recent_posts = new WP_Query(array(
      'showposts' => $posts,
      'cat' => $categories,
));
?>
<?php $counter = 1; while($recent_posts->have_posts()): $recent_posts->the_post(); ?>
<?php
      if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {
      $icon = '<span class="' . get_post_format($post->ID) . '-icon"></span>';
   } else {
      $icon = '';
   }
?>
<?php if($counter == 1): ?>
<div class="showthis">
      <div class="grid-box">
<?php if($images && (has_post_thumbnail() || is_myarcade_game()) ): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'widget-image-thumb'); ?>
<?php if ( empty($image[0]) ) $image[0] = myarcade_get_thumbnail_url(); ?>
      <div class="grid-image"><a class=<?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>"hover_play_small-wp"<?php else: ?>"hover_play_small"<?php endif; ?> href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>

<img src="<?php echo $image[0]; ?>" width="76" height="60" alt="<?php the_title(); ?>" />

</a><?php echo $icon; ?></div>
<?php else: ?>
      <div class="grid-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>

<img src="<?php echo get_template_directory_uri(); ?>/images/thumbnail-76.png" width="76" height="60" alt="<?php the_title(); ?>" />

</a><?php echo $icon; ?></div>
<?php endif; ?>
      <h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<?php if(get_option('tigu_shorten_titles') == 'true'): ?>
<?php $shorttitle = substr(the_title('','',FALSE),0,26); ?><?php echo $shorttitle; if (strlen($shorttitle) >25){ echo '&hellip;'; } ?>
<?php else: ?>
<?php the_title(); ?>
<?php endif; ?>
</a></h2>
<?php if($show_excerpt == 'true'): ?>
      <p><?php echo get_excerpt($smallexcerpt); ?></p>
<?php endif; ?>
<div class="<?php if($show_statistics == 'false'): ?>show-infos<?php endif; ?>">
<div class="clear"></div>
<div class="somepadd block-meta">

<?php if($show_plays_counter == 'true'): ?>
      <?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>
<span class="postviews-wp" title="<?php _e('Views', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?> "><?php _e('Views', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?></span>
<?php else: ?>
<span class="clubs" title="<?php _e('Played', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?> "><?php echo getMostPlayed(get_the_ID()); ?> <?php _e('plays', 'Gameleon'); ?></span>
<?php endif; ?>
<?php endif; ?>

<?php if($show_likes_counter == 'true'): ?>
<span class="minilikes">
<?php _e('Likes', 'Gameleon'); ?>: <?php global $wp_superlike; echo $wp_superlike->show_likes(get_the_ID());?>
</span>
<?php endif; ?>

<?php if($show_comments_counter == 'true'): ?>
   <span class="heading-comments">
<?php if( get_option('tigu_comments_type', 'WordPress') == 'WordPress') : ?>   
<?php comments_popup_link('0','1','%'); ?>
<?php else: ?>
<fb:comments-count href="<?php echo get_permalink($post->ID); ?>"></fb:comments-count>
<?php endif; ?>
</span>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php else: ?>
<div class="showthis">
      <div class="grid-box">
<?php if($images && (has_post_thumbnail() || is_myarcade_game()) ): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'widget-image-thumb'); ?>
<?php if ( empty($image[0]) ) $image[0] = myarcade_get_thumbnail_url(); ?>        
      <div class="grid-image"><a class=<?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>"hover_play_small-wp"<?php else: ?>"hover_play_small"<?php endif; ?> href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<img src="<?php echo $image[0]; ?>" width="76" height="60" alt="<?php the_title(); ?>" />
</a><?php echo $icon; ?></div>
<?php else: ?>
      <div class="grid-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>

<img src="<?php echo get_template_directory_uri(); ?>/images/thumbnail-76.png" width="76" height="60" alt="<?php the_title(); ?>" />

</a><?php echo $icon; ?></div>
<?php endif; ?>
      <h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<?php if(get_option('tigu_shorten_titles') == 'true'): ?>
<?php $shorttitle = substr(the_title('','',FALSE),0,26); ?><?php echo $shorttitle; if (strlen($shorttitle) >25){ echo '&hellip;'; } ?>
<?php else: ?>
<?php the_title(); ?>
<?php endif; ?>
</a></h2>
<?php if($show_excerpt == 'true'): ?>
      <p><?php echo get_excerpt($smallexcerpt); ?></p>
<?php endif; ?>
<div class="<?php if($show_statistics == 'false'): ?>show-infos<?php endif; ?>">
<div class="clear"></div>
<div class="somepadd block-meta">

<?php if($show_plays_counter == 'true'): ?>
      <?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>
<span class="postviews-wp" title="<?php _e('Views', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?> "><?php _e('Views', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?></span>
<?php else: ?>
<span class="clubs" title="<?php _e('Played', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?> "><?php echo getMostPlayed(get_the_ID()); ?> <?php _e('plays', 'Gameleon'); ?></span>
<?php endif; ?>
<?php endif; ?>

<?php if($show_likes_counter == 'true'): ?>
<span class="minilikes">
<?php _e('Likes', 'Gameleon'); ?>: <?php global $wp_superlike; echo $wp_superlike->show_likes(get_the_ID());?>
</span>
<?php endif; ?>

<?php if($show_comments_counter == 'true'): ?>
<span class="heading-comments">
<?php if( get_option('tigu_comments_type', 'WordPress') == 'WordPress') : ?>   
<?php comments_popup_link('0','1','%'); ?>
<?php else: ?>
<fb:comments-count href="<?php echo get_permalink($post->ID); ?>"></fb:comments-count>
<?php endif; ?>
</span>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php $counter++; endwhile; ?>

<!-- **************** START LINKS FIRST ******************** -->
<?php
$post_types = get_post_types();
unset($post_types['page'], $post_types['attachment'], $post_types['revision'], $post_types['nav_menu_item']);
if($post_type_2 == 'all') {
$post_type_2_array = $post_types;
} else {
$post_type_2_array = $post_type;
}
?>

<div class="grid-links">
<div class="half">
<?php
      $recent_posts = new WP_Query(array(
      'showposts' => $posts,
      'cat' => $categories,
      'showposts' => $posts,
      'offset' => $posts,
       )); ?>
<?php $counter = 1; while($recent_posts->have_posts()): $recent_posts->the_post(); ?>
<?php
      if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {
      $icon = '<span class="' . get_post_format($post->ID) . '-icon"></span>';
   } else {
      $icon = '';
   }
?>
<?php if($counter == 1): ?>

<div class="grid-link">

<h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>

<span class="square"></span>
<?php if(get_option('tigu_shorten_titles') == 'true'): ?>
<?php $shorttitle = substr(the_title('','',FALSE),0,26); ?><?php echo $shorttitle; if (strlen($shorttitle) >25){ echo '&hellip;'; } ?>
<?php else: ?>
<?php the_title(); ?>
<?php endif; ?>
</a> - <span class="grid-link-date"><?php the_time('F j, Y') ?></span></h2>

</div>
</div>
<?php else: ?>
      <div class="grid-link">
      <h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<span class="square"></span>
<?php if(get_option('tigu_shorten_titles') == 'true'): ?>
<?php $shorttitle = substr(the_title('','',FALSE),0,26); ?><?php echo $shorttitle; if (strlen($shorttitle) >25){ echo '&hellip;'; } ?>
<?php else: ?>
<?php the_title(); ?>
<?php endif; ?>
</a> - <span class="grid-link-date"><?php the_time('F j, Y') ?></span></h2>
</div>
<?php endif; ?>
<?php $counter++; endwhile; ?>
</div>
<?php if($show_footer_box == 'true'): ?>
<div class="moregames">
<div class="triangle"></div>
<div class="gamesnumber tooltip" title="<?php echo wt_get_category_count(); ?> <?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>
<?php _e('articles in this category', 'Gameleon'); ?>
<?php else: ?>
<?php _e('games in this category', 'Gameleon'); ?>
<?php endif; ?>">
<?php echo wt_get_category_count(); ?>
</div>
<a href="<?php echo get_category_link($categories); ?>"><?php _e('More', 'Gameleon'); ?><div class="arrow-right"></div> <?php echo $title; ?> <?php if($show_aftermore == 'true'): ?><?php echo ($aftermore); ?><?php endif; ?></a>
</div>
<?php endif; ?>

<?php
$post_types = get_post_types();
unset($post_types['page'], $post_types['attachment'], $post_types['revision'], $post_types['nav_menu_item']);
if($post_type_2 == 'all') {
$post_type_2_array = $post_types;
} else {
$post_type_2_array = $post_type;
}
?>
</div>

<!-- ********** END  LINKS FIRST *************** -->

<div class="block half last" style="border-bottom:none">
<div class="grids_box">
      <h3><a href="<?php echo get_category_link($categories_2); ?>"><?php echo $title_2; ?></a></h3>
</div>
<?php
      $recent_posts = new WP_Query(array(
      'showposts' => $posts_2,
      'cat' => $categories_2,
));
?>
<?php $counter = 1; while($recent_posts->have_posts()): $recent_posts->the_post(); ?>
<?php
      if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {
      $icon = '<span class="' . get_post_format($post->ID) . '-icon"></span>';
   } else {
      $icon = '';
   }
?>
<?php if($counter == 1): ?>
<div class="showthis">
      <div class="grid-box">
<?php if($images && (has_post_thumbnail() || is_myarcade_game()) ): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'widget-image-thumb'); ?>
<?php if ( empty($image[0]) ) $image[0] = myarcade_get_thumbnail_url(); ?>
      <div class="grid-image"><a class=<?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>"hover_play_small-wp"<?php else: ?>"hover_play_small"<?php endif; ?> href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<img src="<?php echo $image[0]; ?>" width="76" height="60" alt="<?php the_title(); ?>" />
</a><?php echo $icon; ?></div>
<?php else: ?>
      <div class="grid-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>

<img src="<?php echo get_template_directory_uri(); ?>/images/thumbnail-76.png" width="76" height="60" alt="<?php the_title(); ?>" />

</a><?php echo $icon; ?></div>
<?php endif; ?>
      <h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><?php the_title(); ?></a></h2>
<?php if($show_excerpt == 'true'): ?>
      <p><?php echo get_excerpt($smallexcerpt); ?></p>
<?php endif; ?>
<div class="<?php if($show_statistics == 'false'): ?>show-infos<?php endif; ?>">
<div class="clear"></div>
<div class="somepadd block-meta">
<?php if($show_plays_counter == 'true'): ?>
      <?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>
<span class="postviews-wp" title="<?php _e('Views', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?> "><?php _e('Views', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?></span>
<?php else: ?>
<span class="clubs" title="<?php _e('Played', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?> "><?php echo getMostPlayed(get_the_ID()); ?> <?php _e('plays', 'Gameleon'); ?></span>
<?php endif; ?>
<?php endif; ?>

<?php if($show_likes_counter == 'true'): ?>
<span class="minilikes">
<?php _e('Likes', 'Gameleon'); ?>: <?php global $wp_superlike; echo $wp_superlike->show_likes(get_the_ID());?>
</span>
<?php endif; ?>

<?php if($show_comments_counter == 'true'): ?>
    <span class="heading-comments">
<?php if( get_option('tigu_comments_type', 'WordPress') == 'WordPress') : ?>   
<?php comments_popup_link('0','1','%'); ?>
<?php else: ?>
<fb:comments-count href="<?php echo get_permalink($post->ID); ?>"></fb:comments-count>
<?php endif; ?>
</span>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php else: ?>
<div class="showthis">
      <div class="grid-box">
<?php if($images && (has_post_thumbnail() || is_myarcade_game()) ): ?>
<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), 'widget-image-thumb'); ?>
<?php if ( empty($image[0]) ) $image[0] = myarcade_get_thumbnail_url(); ?>        
      <div class="grid-image"><a class=<?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>"hover_play_small-wp"<?php else: ?>"hover_play_small"<?php endif; ?> href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<img src="<?php echo $image[0]; ?>" width="76" height="60" alt="<?php the_title(); ?>" />

</a><?php echo $icon; ?></div>
<?php else: ?>
      <div class="grid-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>

<img src="<?php echo get_template_directory_uri(); ?>/images/thumbnail-76.png" width="76" height="60" alt="<?php the_title(); ?>" />

</a><?php echo $icon; ?></div>
<?php endif; ?>
      <h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<?php if(get_option('tigu_shorten_titles') == 'true'): ?>
<?php $shorttitle = substr(the_title('','',FALSE),0,26); ?><?php echo $shorttitle; if (strlen($shorttitle) >25){ echo '&hellip;'; } ?>
<?php else: ?>
<?php the_title(); ?>
<?php endif; ?>
</a></h2>
<?php if($show_excerpt == 'true'): ?>
      <p><?php echo get_excerpt($smallexcerpt); ?></p>
<?php endif; ?>
<div class="<?php if($show_statistics == 'false'): ?>show-infos<?php endif; ?>">
<div class="clear"></div>
<div class="somepadd block-meta">
<?php if($show_plays_counter == 'true'): ?>
      <?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>
<span class="postviews-wp" title="<?php _e('Views', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?> "><?php _e('Views', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?></span>
<?php else: ?>
<span class="clubs" title="<?php _e('Played', 'Gameleon'); ?>: <?php echo getMostPlayed(get_the_ID()); ?> "><?php echo getMostPlayed(get_the_ID()); ?> <?php _e('plays', 'Gameleon'); ?></span>
<?php endif; ?>
<?php endif; ?>

<?php if($show_likes_counter == 'true'): ?>
<span class="minilikes">
<?php _e('Likes', 'Gameleon'); ?>: <?php global $wp_superlike; echo $wp_superlike->show_likes(get_the_ID());?>
</span>
<?php endif; ?>

<?php if($show_comments_counter == 'true'): ?>
    <span class="heading-comments">
<?php if( get_option('tigu_comments_type', 'WordPress') == 'WordPress') : ?>   
<?php comments_popup_link('0','1','%'); ?>
<?php else: ?>
<fb:comments-count href="<?php echo get_permalink($post->ID); ?>"></fb:comments-count>
<?php endif; ?>
</span>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php endif; ?>
<?php $counter++; endwhile; ?>
</div>

<!-- ********************* STAR LINKS SECOND ********************** -->

 <div class="block half last" style="border-top:none">
<?php
      $recent_posts = new WP_Query(array(
      'showposts' => $posts_2,
      'cat' => $categories_2,
      'offset' => $posts_2,
));
?>
<?php $counter = 1; while($recent_posts->have_posts()): $recent_posts->the_post(); ?>
<?php
      if(has_post_format('video') || has_post_format('audio') || has_post_format('gallery')) {
      $icon = '<span class="' . get_post_format($post->ID) . '-icon"></span>';
   } else {
      $icon = '';
   }
?>
<?php if($counter == 1): ?>
     <div class="grid-links-last">
     <div class="grid-link">
<h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<span class="square"></span>
<?php if(get_option('tigu_shorten_titles') == 'true'): ?>
<?php $shorttitle = substr(the_title('','',FALSE),0,26); ?><?php echo $shorttitle; if (strlen($shorttitle) >25){ echo '&hellip;'; } ?>
<?php else: ?>
<?php the_title(); ?>
<?php endif; ?>
</a> - <span class="grid-link-date"><?php the_time('F j, Y') ?></span></h2>
</div>
<?php else: ?>
      <div class="grid-link">
<h2><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'>
<span class="square"></span>
<?php if(get_option('tigu_shorten_titles') == 'true'): ?>
<?php $shorttitle = substr(the_title('','',FALSE),0,26); ?><?php echo $shorttitle; if (strlen($shorttitle) >25){ echo '&hellip;'; } ?>
<?php else: ?>
<?php the_title(); ?>
<?php endif; ?>
</a> - <span class="grid-link-date"><?php the_time('F j, Y') ?></span></h2>
</div>
<?php endif; ?>
<?php $counter++; endwhile; ?></div>
<?php if($show_footer_box == 'true'): ?>
<div class="moregames">
<div class="triangle"></div>
<div class="gamesnumber tooltip" title="<?php echo wt_get_category_count(); ?> <?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>
<?php _e('articles in this category', 'Gameleon'); ?>
<?php else: ?>
<?php _e('games in this category', 'Gameleon'); ?>
<?php endif; ?>">
<?php echo wt_get_category_count(); ?>
</div>
<a href="<?php echo get_category_link($categories_2); ?>"><?php _e('More', 'Gameleon'); ?><div class="arrow-right"></div> <?php echo $title_2; ?> <?php if($show_aftermore == 'true'): ?><?php echo ($aftermore); ?><?php endif; ?></a>
</div>
<?php endif; ?>
</div>
<?php endif; ?>

<!-- ******************END LINKS SECOND ******************* -->


<!-- END WIDGET -->

<?php
      echo $after_widget;
   }
   function update($new_instance, $old_instance)
   {
      $instance = $old_instance;
      $instance['show_excerpt'] = $new_instance['show_excerpt'];
      $instance['show_big_excerpt'] = $new_instance['show_big_excerpt'];
      $instance['show_aftermore'] = $new_instance['show_aftermore'];
      $instance['title'] = $new_instance['title'];
      $instance['aftermore'] = $new_instance['aftermore'];
      $instance['post_type'] = 'all';
      $instance['categories'] = $new_instance['categories'];
      $instance['posts'] = $new_instance['posts'];
      $instance['posts_2'] = $new_instance['posts_2'];
      $instance['show_images'] = true;
      $instance['title_2'] = $new_instance['title_2'];
      $instance['bigexcerpt'] = $new_instance['bigexcerpt'];
      $instance['smallexcerpt'] = $new_instance['smallexcerpt'];
      $instance['post_type_2'] = 'all';
      $instance['categories_2'] = $new_instance['categories_2'];
      $instance['show_images_2'] = true;
      $instance['show_plays_counter'] = $new_instance['show_plays_counter'];
      $instance['show_comments_counter'] = $new_instance['show_comments_counter'];
      $instance['show_likes_counter'] = $new_instance['show_likes_counter'];
      $instance['show_footer_box'] = $new_instance['show_footer_box'];
      $instance['show_statistics'] = $new_instance['show_statistics'];
      $instance['show_big_image'] = $new_instance['show_big_image'];
      return $instance;
      }
      function form($instance)
      {
      $defaults = array(
     'show_excerpt' => 'on',
     'show_big_excerpt' => 'on',
     'show_aftermore' => 'on',
     'title' => 'Recent Games',
     'aftermore' => 'articles',
     'show_big_image' => 'on',
     'bigexcerpt' => '126',
     'smallexcerpt' => '60',
     'show_plays_counter' => 'on',
     'show_footer_box' => 'on',
     'show_statistics' => 'on',
     'show_likes_counter' => 'on',
     'show_comments_counter' => 'on',
     'post_type' => 'all',
     'categories' => 'all',
     'posts' => 3,
     'title_2' => 'Recent Games',
     'post_type_2' => 'all',
     'categories_2' => 'all',
     'posts_2' => 3);
      $instance = wp_parse_args((array) $instance, $defaults); ?>

<!-- START ADMIN WIDGETS AREA -->

         <h3>First Category</h3>

      <p>
         <label for="<?php echo $this->get_field_id('title'); ?>">Category Title:</label>
         <input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" />
      </p>

      <p>
         <label for="<?php echo $this->get_field_id('categories'); ?>">Select a Category:</label>
         <select id="<?php echo $this->get_field_id('categories'); ?>" name="<?php echo $this->get_field_name('categories'); ?>" class="widefat categories" style="width:100%;">
         <option value='all' <?php if ('all' == $instance['categories']) echo 'selected="selected"'; ?>>All Categories</option>
<?php $categories = get_categories('hide_empty=0&depth=1&type=post'); ?>
<?php foreach($categories as $category) { ?>
      <option value='<?php echo $category->term_id; ?>' <?php if ($category->term_id == $instance['categories']) echo 'selected="selected"'; ?>><?php echo $category->cat_name; ?></option>
<?php } ?>
      </select>
      </p>

      <p>
         <label for="<?php echo $this->get_field_id('posts'); ?>"><?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>Number of posts to show:<?php else: ?>Number of games to show:<?php endif; ?></label>
         <input class="widefat" style="width: 30px;" id="<?php echo $this->get_field_id('posts'); ?>" name="<?php echo $this->get_field_name('posts'); ?>" value="<?php echo $instance['posts']; ?>" />
      </p>

         <h3 style='margin-top: 40px;'>Second Category</h3>

      <p>
         <label for="<?php echo $this->get_field_id('title_2'); ?>">Category Title:</label>
         <input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('title_2'); ?>" name="<?php echo $this->get_field_name('title_2'); ?>" value="<?php echo $instance['title_2']; ?>" />
      </p>

      <p>
         <label for="<?php echo $this->get_field_id('categories_2'); ?>">Select a Category:</label>
         <select id="<?php echo $this->get_field_id('categories_2'); ?>" name="<?php echo $this->get_field_name('categories_2'); ?>" class="widefat categories" style="width:100%;">
         <option value='all' <?php if ('all' == $instance['categories_2']) echo 'selected="selected"'; ?>>All Categories</option>
<?php $categories = get_categories('hide_empty=0&depth=1&type=post'); ?>
<?php foreach($categories as $category) { ?>
         <option value='<?php echo $category->term_id; ?>' <?php if ($category->term_id == $instance['categories_2']) echo 'selected="selected"'; ?>><?php echo $category->cat_name; ?></option>
<?php } ?>
         </select>
      </p>

      <p>
         <label for="<?php echo $this->get_field_id('posts_2'); ?>"><?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>Number of posts to show:<?php else: ?>Number of games to show:<?php endif; ?></label>
         <input class="widefat" style="width: 30px;" id="<?php echo $this->get_field_id('posts_2'); ?>" name="<?php echo $this->get_field_name('posts_2'); ?>" value="<?php echo $instance['posts_2']; ?>" />
      </p>
<hr style="border:none; background-color: #D1E5EE; height: 1px">
<p>
      <input class="checkbox" type="checkbox" <?php checked($instance['show_big_image'], 'on'); ?> id="<?php echo $this->get_field_id('show_big_image'); ?>" name="<?php echo $this->get_field_name('show_big_image'); ?>" />
      <label for="<?php echo $this->get_field_id('show_big_image'); ?>">Show Big Image on Top</label><br />
<small>If unchecked, the widget will display the number of posts you've set with regular image size, plus as many posts title - only links.</small>
    </p>

<p>
         <input class="checkbox" type="checkbox" <?php checked($instance['show_big_excerpt'], 'on'); ?> id="<?php echo $this->get_field_id('show_big_excerpt'); ?>" name="<?php echo $this->get_field_name('show_big_excerpt'); ?>" />
         <label for="<?php echo $this->get_field_id('show_big_excerpt'); ?>">Display the excerpt below Big Image</label>
      </p>

      <p>
         <label for="<?php echo $this->get_field_id('bigexcerpt'); ?>">Excerpt Length below Big Image:</label>
         <input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('bigexcerpt'); ?>" name="<?php echo $this->get_field_name('bigexcerpt'); ?>" value="<?php echo $instance['bigexcerpt']; ?>" />
      <small>Default is 126</small>
</p>
 <p>
         <input class="checkbox" type="checkbox" <?php checked($instance['show_excerpt'], 'on'); ?> id="<?php echo $this->get_field_id('show_excerpt'); ?>" name="<?php echo $this->get_field_name('show_excerpt'); ?>" />
         <label for="<?php echo $this->get_field_id('show_excerpt'); ?>">Display the excerpt near thumbnails</label>
      </p>
 <p>
         <label for="<?php echo $this->get_field_id('smallexcerpt'); ?>">Excerpt Length near thumbnails:</label>
         <input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('smallexcerpt'); ?>" name="<?php echo $this->get_field_name('smallexcerpt'); ?>" value="<?php echo $instance['smallexcerpt']; ?>" />
      <small>Default is 60</small>
</p>
      <input class="checkbox" type="checkbox" <?php checked($instance['show_plays_counter'], 'on'); ?> id="<?php echo $this->get_field_id('show_plays_counter'); ?>" name="<?php echo $this->get_field_name('show_plays_counter'); ?>" />
      <label for="<?php echo $this->get_field_id('show_plays_counter'); ?>"><?php if( get_option('tigu_template_type', 'WordPres Default') == 'WordPres Default') : ?>Display Views Counter<?php else: ?>Display Plays Counter<?php endif; ?></label>
    </p>
 <p>
      <input class="checkbox" type="checkbox" <?php checked($instance['show_likes_counter'], 'on'); ?> id="<?php echo $this->get_field_id('show_likes_counter'); ?>" name="<?php echo $this->get_field_name('show_likes_counter'); ?>" />
      <label for="<?php echo $this->get_field_id('show_likes_counter'); ?>">Display Likes Counter</label>
    </p>

  <p>
      <input class="checkbox" type="checkbox" <?php checked($instance['show_comments_counter'], 'on'); ?> id="<?php echo $this->get_field_id('show_comments_counter'); ?>" name="<?php echo $this->get_field_name('show_comments_counter'); ?>" />
      <label for="<?php echo $this->get_field_id('show_comments_counter'); ?>">Display Comments Counter</label>
    </p>


<p>
      <input class="checkbox" type="checkbox" <?php checked($instance['show_statistics'], 'on'); ?> id="<?php echo $this->get_field_id('show_statistics'); ?>" name="<?php echo $this->get_field_name('show_statistics'); ?>" />
      <label for="<?php echo $this->get_field_id('show_statistics'); ?>">Statistics Permanently Visible</label>
    </p>

<p>
      <input class="checkbox" type="checkbox" <?php checked($instance['show_footer_box'], 'on'); ?> id="<?php echo $this->get_field_id('show_footer_box'); ?>" name="<?php echo $this->get_field_name('show_footer_box'); ?>" />
      <label for="<?php echo $this->get_field_id('show_footer_box'); ?>">Show Footer Box</label>
    </p>
<p>
      <input class="checkbox" type="checkbox" <?php checked($instance['show_aftermore'], 'on'); ?> id="<?php echo $this->get_field_id('show_aftermore'); ?>" name="<?php echo $this->get_field_name('show_aftermore'); ?>" />
      <label for="<?php echo $this->get_field_id('show_aftermore'); ?>">Show text after More [Category Title]</label>
    <small>*This option is applicable only if <strong>Show Footer Box</strong> option above is checked.</small>
</p>
      <p>
         <label for="<?php echo $this->get_field_id('aftermore'); ?>">More [Category Title] Text on Footer Box:</label>
         <input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('aftermore'); ?>" name="<?php echo $this->get_field_name('aftermore'); ?>" value="<?php echo $instance['aftermore']; ?>" />
     <small>On the footer box, there is a <strong>More [category tite] articles</strong> text. For example, let's suppose we have a <strong>Aventure</strong> category. The footer box will display: More Aventure <strong>articles</strong>. This options allows you to change that text after category title (<strong>articles</strong> in our example).</small><br />
<small>*This option is applicable only if <strong>Show Footer Box</strong> and <strong>Show text after More [Category Title]</strong> options above are checked.</small>
 </p>

<!-- END ADMIN WIDGETS AREA -->

<?php }
}
?>