function adelante_widgetbox($atts, $content = null)
 {
     extract(shortcode_atts(array('title' => '', 'icon' => ''), $atts));
     if ($icon == "none") {
         $img = "";
     } else {
         $img = '<img class="icon" src="' . adelante_image_resize(40, 40, ADELANTE_BASE_URI . '/img/icons/iconbox/' . $icon) . '" alt="" />';
     }
     return '<article class="widgetbox"><div class="inner"><h3>' . $title . $img . '</h3><div>' . do_shortcode($content) . '</div></div></article>';
 }
    function widget($args, $instance)
    {
        $cache = wp_cache_get('theme_widget_related_posts', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        ob_start();
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Related Posts', 'adelante') : $instance['title'], $instance, $this->id_base);
        if (!($number = (int) $instance['number'])) {
            $number = 10;
        } else {
            if ($number < 1) {
                $number = 1;
            } else {
                if ($number > 15) {
                    $number = 15;
                }
            }
        }
        if (!($desc_length = (int) $instance['desc_length'])) {
            $desc_length = 80;
        } else {
            if ($desc_length < 1) {
                $desc_length = 1;
            }
        }
        $disable_thumbnail = $instance['disable_thumbnail'] ? '1' : '0';
        $display_extra_type = $instance['display_extra_type'] ? $instance['display_extra_type'] : 'time';
        global $post;
        $tags = wp_get_post_tags($post->ID);
        $tagIDs = array();
        if ($tags) {
            $tagcount = count($tags);
            for ($i = 0; $i < $tagcount; $i++) {
                $tagIDs[$i] = $tags[$i]->term_id;
            }
            $query = array('tag__in' => $tagIDs, 'post__not_in' => array($post->ID), 'showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'caller_get_posts' => 1);
            if (!empty($instance['cat'])) {
                $query['cat'] = implode(',', $instance['cat']);
            }
            $r = new WP_Query($query);
            if ($r->have_posts()) {
                ?>
		<?php 
                echo $before_widget;
                ?>
		<?php 
                if ($title) {
                    echo $before_title . $title . $after_title;
                }
                ?>
		<ul class="posts_list">
<?php 
                while ($r->have_posts()) {
                    $r->the_post();
                    ?>
			<li>
<?php 
                    if (!$disable_thumbnail) {
                        ?>
            <figure class="widget-related-img">
                <a class="thumbnail" href="<?php 
                        echo get_permalink();
                        ?>
" title="<?php 
                        the_title();
                        ?>
">
                    <?php 
                        if (has_post_thumbnail()) {
                            ?>
                    
                        <?php 
                            $thumb = get_post_thumbnail_id($r->post->ID);
                            $image = wp_get_attachment_image_src($thumb, 'full');
                            ?>
                        <img src="<?php 
                            echo adelante_image_resize(65, 65, "http://" . $_SERVER['SERVER_NAME'] . $image[0]);
                            ?>
" alt="<?php 
                            the_title();
                            ?>
" title="<?php 
                            the_title();
                            ?>
" />        
                    <?php 
                        } else {
                            ?>
                        <img src="<?php 
                            echo adelante_image_resize(65, 65, ADELANTE_BASE_URI . "/img/empty_thumb.png");
                            ?>
" alt="<?php 
                            the_title();
                            ?>
" title="<?php 
                            the_title();
                            ?>
" />
                    <?php 
                        }
                        ?>
                   
                </a>
                <?php 
                        adelante_image_border(null, 3, 0.1);
                        ?>
             </figure>
<?php 
                    }
                    //disable_thumbnail
                    ?>
				<div class="post_extra_info">
					<a href="<?php 
                    the_permalink();
                    ?>
" rel="bookmark" title="<?php 
                    echo esc_attr(get_the_title() ? get_the_title() : get_the_ID());
                    ?>
"><?php 
                    if (get_the_title()) {
                        the_title();
                    } else {
                        the_ID();
                    }
                    ?>
</a>
<?php 
                    if ($display_extra_type == 'time') {
                        ?>
					<time datetime="<?php 
                        the_time('Y-m-d');
                        ?>
"><?php 
                        echo get_the_date();
                        ?>
</time>
<?php 
                    } else {
                        ?>
					<p><?php 
                        echo wp_html_excerpt(get_the_excerpt(), $desc_length);
                        ?>
...</p>
<?php 
                    }
                    //end display extra type
                    ?>
				</div>
				<div class="clearboth"></div>
			</li>
<?php 
                }
                ?>
		</ul>
		<?php 
                echo $after_widget;
                // Reset the global $the_post as this query will have stomped on it
                wp_reset_query();
            }
            $cache[$args['widget_id']] = ob_get_flush();
            wp_cache_set('theme_widget_related_posts', $cache, 'widget');
        }
    }
function adelante_posts_slider($width = 960)
{
    global $post;
    $i = 1;
    $height = get_option('adelante_slider_height');
    // Check what post types to include in slider
    $post_types = adelante_get_post_types(false, false);
    foreach ($post_types as $post_type) {
        $inc = get_option('adelante_slider_' . $post_type);
        if ($inc == 'checked') {
            $types[] = $post_type;
        }
    }
    adelante_buffer_start();
    // Start outputting
    echo '<ul>';
    $args = array('post_type' => $types);
    $ppp = get_option('adelante_slider_post_count');
    if ($ppp > 0) {
        $args['posts_per_page'] = $ppp;
    }
    query_posts($args);
    if (have_posts()) {
        while (have_posts()) {
            the_post();
            $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'large');
            ?>
            <li id="slide-<?php 
            echo $i++;
            ?>
" class="slide clearboth">
                <div class="thumb clearfix">
                    <a href="<?php 
            the_permalink();
            ?>
">
                        <?php 
            if (!empty($thumbnail[0])) {
                ?>
                            <figure class="gallery-item aligncenter"><img class="featured_image post" src="<?php 
                echo adelante_image_resize($height - 21, $width - 410, $thumbnail[0]);
                ?>
" alt="<?php 
                the_title();
                ?>
" /><?php 
                adelante_image_border(null, 10, 0.05);
                ?>
</figure>
                        <?php 
            } else {
                ?>
                            <figure class="gallery-item aligncenter"><img class="featured_image post" src="<?php 
                echo adelante_image_resize($height - 21, $width - 410, get_template_directory_uri() . "/img/placeholder.png");
                ?>
" alt="placeholder" /></figure>
                        <?php 
            }
            ?>
                    </a>
                    <div class="postsnip">
                        <h2><a href="<?php 
            the_permalink();
            ?>
"><?php 
            echo $post->post_title;
            ?>
</a></h2>
                        <?php 
            the_excerpt();
            ?>
                        <p></p><div class="clearboth"></div>
                        <a class="adelante-button white" href="<?php 
            the_permalink();
            ?>
" title="<?php 
            the_title();
            ?>
">Read More...</a>
                    </div>
                </div>
               
            </li>            
        <?php 
        }
    } else {
        $output .= '<figure class="gallery-item aligncenter"><a href="' . site_url() . '/wp-admin/post-new.php?post_type=slider"><img class="post" src="' . adelante_image_resize($height - 21, $width - 410, get_template_directory_uri() . "/img/placeholder.png") . '" alt="placeholder" title="Please add items to your slider by clicking on this slide" /></a></figure>';
    }
    echo '</ul>';
    wp_reset_query();
    $output = ob_get_contents();
    adelante_buffer_end();
    return $output;
}