Пример #1
0
function is_tablet_but_ipad()
{
    return is_samsung_galaxy_tab() || is_kindle() || is_nexus();
}
Пример #2
0
    function widget($args, $instance)
    {
        $cache = wp_cache_get('widget_dw_focus_recent_posts', 'widget');
        if (!is_array($cache)) {
            $cache = array();
        }
        if (!isset($args['widget_id'])) {
            $args['widget_id'] = $this->id;
        }
        if (isset($cache[$args['widget_id']])) {
            echo $cache[$args['widget_id']];
            return;
        }
        ob_start();
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts', 'dw_focus') : $instance['title'], $instance, $this->id_base);
        if (empty($instance['number']) || !($number = absint($instance['number']))) {
            $number = 10;
        }
        $interval = isset($instance['interval']) ? $instance['interval'] : 0;
        $tax_query = array();
        if (!empty($instance['post-format'])) {
            $tax_query = array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-' . $instance['post-format']), 'operator' => 'IN'));
        }
        $r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'category__in' => $instance['category'], 'tax_query' => $tax_query)));
        if (is_mobile() || is_kindle() || is_samsung_galaxy_tab() || is_nexus()) {
            $col = 1;
            $row = 1;
            $size = 'large';
        } else {
            $col = 4;
            $row = 4;
            $size = 'medium';
        }
        if ($r->have_posts()) {
            $i = 0;
            //Dectect first post
            ?>
        
        <?php 
            echo $before_widget;
            ?>
        <?php 
            echo $before_title . $title . $after_title;
            ?>
        <div id="dwqa-news-carousel-<?php 
            echo $this->id;
            ?>
" class="carousel slide" data-pause="hover" data-interval="<?php 
            echo $interval > 0 ? $interval * 1000 : 'false';
            ?>
">
            <div class="carousel-inner">
                <div class="active item">
                    <div class="row-fluid">
            <?php 
            $i = 0;
            while ($r->have_posts()) {
                $r->the_post();
                ?>
                <?php 
                if ($i != 0 && $i % $col == 0) {
                    ?>
                    </div>
                </div>
                <div class="item">
                    <div class="row-fluid">
                <?php 
                }
                ?>
                    <?php 
                $class = 'span3';
                if (has_post_thumbnail(get_the_ID())) {
                    $class .= ' has-thumbnail';
                }
                ?>
                    <article <?php 
                post_class($class);
                ?>
>
                        <?php 
                if (has_post_thumbnail(get_the_ID())) {
                    ?>
                        <div class="entry-thumbnail">
                            <a href="<?php 
                    the_permalink();
                    ?>
" title="<?php 
                    echo esc_attr(get_the_title() ? get_the_title() : get_the_ID());
                    ?>
">
                                <?php 
                    echo dw_focus_post_format_icons($this);
                    ?>
                                <?php 
                    the_post_thumbnail($size);
                    ?>
                            </a>
                        </div>
                        <?php 
                }
                ?>
                        <h2 class="entry-title"><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                echo esc_attr(get_the_title() ? get_the_title() : get_the_ID());
                ?>
"><?php 
                the_title();
                ?>
</a></h2>
                        <div class="entry-meta">
                            <time datetime="<?php 
                echo get_post_time('c');
                ?>
" class="entry-date"><?php 
                echo get_post_time('d.m.Y');
                ?>
</time>
                        </div>
                    </article>
            <?php 
                $i++;
            }
            ?>
                    </div>
                </div>
            </div>

            <a class="carousel-control left" href="#dwqa-news-carousel-<?php 
            echo $this->id;
            ?>
" data-slide="prev"><i class="icon-chevron-left"></i></a>
            <a class="carousel-control right" href="#dwqa-news-carousel-<?php 
            echo $this->id;
            ?>
" data-slide="next"><i class="icon-chevron-right"></i></a>
            <div class="carousel-nav"><ul></ul></div>
        </div>
        <?php 
            echo $after_widget;
            // Reset the global $the_post as this query will have stomped on it
            wp_reset_postdata();
        }
        $cache[$args['widget_id']] = ob_get_flush();
        wp_cache_set('widget_recent_posts', $cache, 'widget');
    }