<article class="<?php 
xtreme_post_class();
?>
" id="post-<?php 
the_ID();
?>
">
	<header>
		<?php 
xtreme_post_format_icon('h3', __('Gallery', XF_TEXTDOMAIN));
?>
		<?php 
xtreme_post_titles();
?>
		<?php 
xtreme_html5_byline();
?>
	</header>
	<?php 
$images = get_children(array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999));
if ($images) {
    $total_images = count($images);
    $image = array_shift($images);
    $image_img_tag = wp_get_attachment_image($image->ID, 'thumbnail');
    $align = apply_filters('xtreme_loop_thumbnail_align', 'alignleft');
    ?>
		<figure class="gallery-thumnail">
			<a class="xf-thumbnail <?php 
    echo $align;
    ?>
" title="<?php 
    public function widget($args, $instance)
    {
        global $wpdb;
        extract($args);
        $number_posts = absint($instance['number_posts']);
        /* @since 09/26/2013 */
        $post_type = isset($instance['post_type']) ? esc_attr($instance['post_type']) : 'post';
        $columns = absint($instance['columns']);
        $thumbnail_size = esc_attr($instance['thumbnail_size']);
        /* since 1.01 */
        $contentorder = array('content' => isset($instance['content_pos']) ? (int) $instance['content_pos'] : 4, 'byline' => isset($instance['byline_pos']) ? (int) $instance['byline_pos'] : 3, 'subtitle' => isset($instance['subtitle_pos']) ? (int) $instance['subtitle_pos'] : 3, 'posttitle' => isset($instance['posttitle_pos']) ? (int) $instance['posttitle_pos'] : 2, 'thumbnail' => isset($instance['image_pos']) ? (int) $instance['image_pos'] : 1);
        /* since 1.1 */
        $title_tag = isset($instance['title_tag']) ? esc_attr($instance['title_tag']) : 'h3';
        $tag = isset($instance['posttitle_tag']) ? esc_attr($instance['posttitle_tag']) : 'h2';
        $subtag = isset($instance['subtitle_tag']) ? esc_attr($instance['subtitle_tag']) : 'h3';
        if (!isset($instance['content_pos'])) {
            $instance['show_posttitle'] = 1;
            $instance['show_content'] = 1;
            $instance['sticky'] = 0;
        }
        $suppress_posttitle_link = isset($instance['suppress_posttitle_link']) ? (bool) ($instance['suppress_posttitle_link'] == 1) : false;
        $suppress_postthumbnail_link = isset($instance['suppress_postthumbnail_link']) ? (bool) ($instance['suppress_postthumbnail_link'] == 1) : false;
        $suppress_category_link = isset($instance['suppress_category_link']) ? (bool) ($instance['suppress_category_link'] == 1) : false;
        if (!isset($instance['show_subtitle'])) {
            $instance['show_subtitle'] = 0;
        }
        asort($contentorder, SORT_NUMERIC);
        foreach ($contentorder as $key => $value) {
            if ($instance['show_' . $key]) {
                $new_sort[] = $key;
            }
        }
        $el = 'div';
        $html5 = xtreme_is_html5();
        if ($html5) {
            $el = 'article';
        }
        echo $before_widget;
        if ($columns !== 1) {
            echo '<div class="ym-grid linearize-level-1">';
        }
        for ($i = 0; $i < $columns; $i++) {
            if ($columns !== 1) {
                echo "<div class='" . $this->classes[$columns][$i]['outer'] . "'>\n";
                echo "<div class='" . $this->classes[$columns][$i]['inner'] . "'>\n";
            }
            /* @since 09/26/2013 */
            $tax_names = get_object_taxonomies($post_type);
            if (!empty($tax_names) && in_array('category', $tax_names)) {
                $category = $instance['category-' . $i];
            } else {
                $category = '';
            }
            $r = new WP_Query(array('cat' => $category, 'showposts' => $number_posts, 'offset' => (int) $instance['offset'], 'nopaging' => 0, 'post_type' => $post_type, 'post_status' => 'publish', XF_STICKY_HANDLING => 1, 'orderby' => esc_attr($instance['orderby']), 'order' => esc_attr(strtoupper($instance['sort']))));
            if ($r->have_posts()) {
                $x = 0;
                while ($r->have_posts()) {
                    $r->the_post();
                    $x++;
                    if ($x === 1 && '' !== $category && $instance['title']) {
                        if ((int) $instance['category-' . $i] === 0) {
                            $title = __('All Categories', XF_TEXTDOMAIN);
                            $cls = 'category-all';
                        } else {
                            $cat = get_category($instance['category-' . $i]);
                            $cls = 'category-' . $cat->slug;
                            if (!$suppress_category_link) {
                                $title = '<a href="' . esc_attr(get_category_link($instance['category-' . $i])) . '">' . esc_attr($cat->name) . '</a>';
                            } else {
                                $title = esc_attr($cat->name);
                            }
                        }
                        echo '<' . $title_tag . ' class="widget-title ' . $cls . '">' . $title . '</' . $title_tag . '>';
                    }
                    ?>
					<<?php 
                    echo $el;
                    ?>
 <?php 
                    post_class();
                    ?>
>
					<?php 
                    if (isset($new_sort)) {
                        $c = count($new_sort);
                        for ($y = 0; $y < $c; $y++) {
                            switch ($new_sort[$y]) {
                                case 'thumbnail':
                                    if (!$suppress_postthumbnail_link) {
                                        xtreme_post_thumbnail($thumbnail_size, esc_attr($instance['image_alignment']));
                                    } else {
                                        xtreme_widget_post_thumbnail($thumbnail_size, esc_attr($instance['image_alignment']));
                                    }
                                    break;
                                case 'subtitle':
                                    xtreme_widget_post_subtitle($subtag);
                                    break;
                                case 'posttitle':
                                    if ($html5) {
                                        echo '<header>';
                                    }
                                    xtreme_widget_post_headline($tag, !$suppress_posttitle_link);
                                    if ($html5 && $new_sort[$y + 1] !== 'byline') {
                                        echo '</header>';
                                    }
                                    break;
                                case 'byline':
                                    if (!$html5) {
                                        xtreme_byline();
                                    } else {
                                        xtreme_html5_byline();
                                        if ($new_sort[$y - 1] == 'posttitle') {
                                            echo '</header>';
                                        }
                                    }
                                    break;
                                case 'content':
                                    echo '<div class="entry-content">';
                                    switch ($instance['content_type']) {
                                        case 'xtreme_excerpt':
                                            xtreme_excerpt($instance['excerpt_length'], esc_html($instance['excerpt_morelink_text']), esc_html($instance['excerpt_more']));
                                            break;
                                        case 'excerpt':
                                            $new_excerpt = wptexturize(get_the_excerpt());
                                            echo "<p>{$new_excerpt} <span class='read-more'><a href='" . get_permalink() . "' title='" . __('Read more about', XF_TEXTDOMAIN) . ' ' . esc_attr(get_the_title()) . "'>" . esc_html($instance['excerpt_morelink_text']) . "</a></span></p>";
                                            break;
                                        case 'content':
                                            the_content();
                                            break;
                                    }
                                    echo '</div>';
                                    break;
                            }
                        }
                        echo '</' . $el . '>';
                    }
                }
                if ($columns !== 1) {
                    echo "</div></div>";
                }
                wp_reset_query();
            } else {
                echo __('No Posts so far.', XF_TEXTDOMAIN) . '</div></div>';
            }
        }
        if ($columns !== 1) {
            echo '</div>';
        }
        echo $after_widget;
    }
    function widget($args, $instance)
    {
        global $wpdb;
        extract($args);
        $title = empty($instance['title']) ? '' : $instance['title'];
        $title = apply_filters('widget_title', $title);
        $columns = absint($instance['columns']);
        $thumbnail_size = esc_attr($instance['thumbnail_size']);
        $el = 'div';
        $html5 = xtreme_is_html5();
        if ($html5) {
            $el = 'article';
        }
        $contentorder = array('content' => isset($instance['content_pos']) ? (int) $instance['content_pos'] : 4, 'byline' => isset($instance['byline_pos']) ? (int) $instance['byline_pos'] : 3, 'posttitle' => isset($instance['posttitle_pos']) ? (int) $instance['posttitle_pos'] : 2, 'thumbnail' => isset($instance['image_pos']) ? (int) $instance['image_pos'] : 1);
        $suppress_posttitle_link = isset($instance['suppress_posttitle_link']) ? (bool) ($instance['suppress_posttitle_link'] == 1) : false;
        $tag = isset($instance['posttitle_tag']) ? esc_attr($instance['posttitle_tag']) : 'h2';
        if (!isset($instance['content_pos'])) {
            $instance['show_posttitle'] = 1;
            $instance['show_content'] = 1;
        }
        asort($contentorder, SORT_NUMERIC);
        foreach ($contentorder as $key => $value) {
            if ($instance['show_' . $key]) {
                $new_sort[] = $key;
            }
        }
        echo $before_widget;
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        echo '<div>';
        for ($i = 0; $i < $columns; $i++) {
            $key = 'category-' . $i;
            if (!array_key_exists($key, $instance)) {
                continue;
            }
            $query_args = array('cat' => $instance[$key], 'showposts' => 1, 'offset' => (int) $instance['offset'], 'nopaging' => 0, 'post_type' => 'post', 'post_status' => 'publish', 'orderby' => esc_attr($instance['orderby']));
            $r = new WP_Query($query_args);
            if (!$r->have_posts()) {
                continue;
            }
            while ($r->have_posts()) {
                $r->the_post();
                $cat = get_category($instance[$key]);
                if (is_wp_error($cat)) {
                    continue;
                }
                $cls = 'category-' . $cat->slug;
                ?>
				<<?php 
                echo $el;
                ?>
 class="<?php 
                echo join(' ', get_post_class('tab-content'));
                ?>
">
					<h5 class="<?php 
                echo $cls;
                ?>
" id="<?php 
                echo $cls;
                ?>
"><?php 
                echo esc_attr($cat->name);
                ?>
</h5>
					<?php 
                if (isset($new_sort)) {
                    $c = count($new_sort);
                    for ($y = 0; $y < $c; $y++) {
                        switch ($new_sort[$y]) {
                            case 'thumbnail':
                                xtreme_post_thumbnail($thumbnail_size, esc_attr($instance['image_alignment']));
                                break;
                            case 'posttitle':
                                if ($html5) {
                                    echo '<header>';
                                }
                                xtreme_widget_post_headline($tag, !$suppress_posttitle_link);
                                if ($html5 && ($y + 1 >= $c || $new_sort[$y + 1] !== 'byline')) {
                                    echo '</header>';
                                }
                                break;
                            case 'byline':
                                if (!$html5) {
                                    xtreme_byline();
                                } else {
                                    xtreme_html5_byline();
                                    if ($y - 1 >= 0 && $new_sort[$y - 1] == 'posttitle') {
                                        echo '</header>';
                                    }
                                }
                                break;
                            case 'content':
                                echo '<div class="entry-content">';
                                switch ($instance['content_type']) {
                                    case 'xtreme_excerpt':
                                        xtreme_excerpt($instance['excerpt_length'], esc_html($instance['excerpt_morelink_text']), esc_html($instance['excerpt_more']));
                                        break;
                                    case 'excerpt':
                                        $new_excerpt = wptexturize(get_the_excerpt());
                                        echo "<p>{$new_excerpt} <span class='read-more'><a href='" . get_permalink() . "' title='" . __('Read more about', XF_TEXTDOMAIN) . ' ' . esc_attr(get_the_title()) . "'>" . esc_html($instance['excerpt_morelink_text']) . "</a></span></p>";
                                        break;
                                    case 'content':
                                    default:
                                        the_content();
                                        break;
                                }
                                echo '</div>';
                                break;
                        }
                    }
                    echo '</' . $el . '>';
                }
            }
            wp_reset_query();
        }
        echo "</div>";
        echo $after_widget;
    }
    function widget($args, $instance)
    {
        global $wpdb;
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
        if ($instance['number_posts'] < 1) {
            $instance['number_posts'] = 1;
        }
        $columns = absint($instance['columns']);
        $rows = absint($instance['rows']);
        $thumbnail_size = esc_attr($instance['thumbnail_size']);
        if (!isset($instance['as_backgroundimage'])) {
            $instance['as_backgroundimage'] = 0;
        }
        if (!isset($instance['wrap_content'])) {
            $instance['wrap_content'] = 1;
        }
        $el = 'div';
        $html5 = xtreme_is_html5();
        if ($html5) {
            $el = 'article';
        }
        $contentorder = array('content' => isset($instance['content_pos']) ? (int) $instance['content_pos'] : 4, 'byline' => isset($instance['byline_pos']) ? (int) $instance['byline_pos'] : 3, 'subtitle' => isset($instance['subtitle_pos']) ? (int) $instance['subtitle_pos'] : 3, 'posttitle' => isset($instance['posttitle_pos']) ? (int) $instance['posttitle_pos'] : 2, 'thumbnail' => isset($instance['image_pos']) ? (int) $instance['image_pos'] : 1);
        $suppress_posttitle_link = isset($instance['suppress_posttitle_link']) ? (bool) ($instance['suppress_posttitle_link'] == 1) : false;
        $tag = isset($instance['posttitle_tag']) ? esc_attr($instance['posttitle_tag']) : 'h2';
        $subtag = isset($instance['subtitle_tag']) ? esc_attr($instance['subtitle_tag']) : 'h3';
        if (!isset($instance['content_pos'])) {
            $instance['show_posttitle'] = 1;
            $instance['show_content'] = 1;
            $instance['sticky'] = 0;
        }
        if (!isset($instance['show_subtitle'])) {
            $instance['show_subtitle'] = 0;
        }
        asort($contentorder, SORT_NUMERIC);
        foreach ($contentorder as $key => $value) {
            if ($instance['show_' . $key]) {
                $new_sort[] = $key;
            }
        }
        $query_args = array('showposts' => (int) $instance['number_posts'], 'offset' => (int) $instance['offset'], 'nopaging' => 0, 'post_type' => 'post', 'post_status' => 'publish', XF_STICKY_HANDLING => (bool) $instance['sticky'], 'orderby' => esc_attr($instance['orderby']));
        if ($query_args[XF_STICKY_HANDLING] === true) {
            $query_args['post__not_in'] = get_option('sticky_posts');
        }
        if (array_key_exists('hide_child_cat', $instance) && (bool) $instance['hide_child_cat']) {
            $query_args['category__in'] = $instance['category'];
        } else {
            $query_args['cat'] = $instance['category'];
        }
        $r = new WP_Query($query_args);
        if ($r->have_posts()) {
            $i = 0;
            $count = $r->post_count;
            echo $before_widget;
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            while ($r->have_posts()) {
                $r->the_post();
                $i++;
                echo $this->html_before($columns, $i, $instance['use_box_bottom']);
                ?>
				<<?php 
                echo $el;
                ?>
 <?php 
                post_class();
                ?>
>
				<?php 
                if (isset($new_sort)) {
                    $c = count($new_sort);
                    for ($y = 0; $y < $c; $y++) {
                        switch ($new_sort[$y]) {
                            case 'thumbnail':
                                if ($instance['as_backgroundimage'] == 0) {
                                    xtreme_post_thumbnail($thumbnail_size, esc_attr($instance['image_alignment']));
                                } else {
                                    xtreme_background_post_thumbnail($thumbnail_size, esc_attr($instance['image_alignment']), esc_html($instance['excerpt_morelink_text']));
                                }
                                break;
                            case 'subtitle':
                                xtreme_widget_post_subtitle($subtag);
                                break;
                            case 'posttitle':
                                if ($html5) {
                                    echo '<header>';
                                }
                                xtreme_widget_post_headline($tag, !$suppress_posttitle_link);
                                if ($html5 && $new_sort[$y + 1] !== 'byline') {
                                    echo '</header>';
                                }
                                break;
                            case 'byline':
                                if (!$html5) {
                                    xtreme_byline();
                                } else {
                                    xtreme_html5_byline();
                                    if ($new_sort[$y - 1] == 'posttitle') {
                                        echo '</header>';
                                    }
                                }
                                break;
                            case 'content':
                                if ($instance['wrap_content'] == 1) {
                                    echo '<div class="entry-content">';
                                }
                                switch ($instance['content_type']) {
                                    case 'xtreme_excerpt':
                                        if (!$instance['use_box_bottom']) {
                                            xtreme_excerpt($instance['excerpt_length'], esc_html($instance['excerpt_morelink_text']), esc_html($instance['excerpt_more']));
                                        } else {
                                            xtreme_excerpt($instance['excerpt_length'], '', esc_html($instance['excerpt_more']));
                                        }
                                        break;
                                    case 'excerpt':
                                        the_excerpt();
                                        if (!$instance['use_box_bottom']) {
                                            echo " <p><span class='read-more'><a href='" . get_permalink() . "' title='" . __('Read more about', XF_TEXTDOMAIN) . ' ' . esc_attr(get_the_title()) . "'>" . esc_html($instance['excerpt_morelink_text']) . "</a></span></p>";
                                        }
                                        break;
                                }
                                if ($instance['wrap_content'] == 1) {
                                    echo '</div>';
                                }
                                break;
                        }
                    }
                    echo '</' . $el . '>';
                    $link[] = array('url' => get_permalink(), 'title' => get_the_title());
                    echo $this->html_after($columns, $i, $instance['use_box_bottom'], $link, esc_html($instance['excerpt_morelink_text']));
                }
            }
            wp_reset_query();
            $rest = $i % $columns;
            if ($rest !== 0) {
                while ($rest < $columns) {
                    $rest++;
                    $i++;
                    $link[] = array('url' => '#blank', 'title' => '');
                    echo $this->html_before($columns, $rest, $instance['use_box_bottom']);
                    echo "&nbsp;";
                    echo $this->html_after($columns, $i, $instance['use_box_bottom'], $link, esc_html($instance['excerpt_morelink_text']));
                }
            }
            echo $after_widget;
        }
        unset($link);
    }
Example #5
0
    public function widget($args, $instance)
    {
        global $wpdb;
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title']);
        if ($instance['number_posts'] < 1) {
            $instance['number_posts'] = 1;
        }
        /* @since 09/26/2013 */
        $post_type = isset($instance['post_type']) ? esc_attr($instance['post_type']) : 'post';
        $columns = absint($instance['columns']);
        $rows = absint($instance['rows']);
        $thumbnail_size = esc_attr($instance['thumbnail_size']);
        if (!isset($instance['as_backgroundimage'])) {
            $instance['as_backgroundimage'] = 0;
        }
        if (!isset($instance['wrap_content'])) {
            $instance['wrap_content'] = 1;
        }
        $el = 'div';
        $html5 = xtreme_is_html5();
        if ($html5) {
            $el = 'article';
        }
        /* since 1.01 */
        $contentorder = array('content' => isset($instance['content_pos']) ? (int) $instance['content_pos'] : 4, 'byline' => isset($instance['byline_pos']) ? (int) $instance['byline_pos'] : 3, 'subtitle' => isset($instance['subtitle_pos']) ? (int) $instance['subtitle_pos'] : 3, 'posttitle' => isset($instance['posttitle_pos']) ? (int) $instance['posttitle_pos'] : 2, 'thumbnail' => isset($instance['image_pos']) ? (int) $instance['image_pos'] : 1);
        $suppress_posttitle_link = isset($instance['suppress_posttitle_link']) ? (bool) ($instance['suppress_posttitle_link'] == 1) : false;
        $tag = isset($instance['posttitle_tag']) ? esc_attr($instance['posttitle_tag']) : 'h2';
        $subtag = isset($instance['subtitle_tag']) ? esc_attr($instance['subtitle_tag']) : 'h3';
        if (!isset($instance['content_pos'])) {
            $instance['show_posttitle'] = 1;
            $instance['show_content'] = 1;
            $instance['sticky'] = 0;
        }
        if (!isset($instance['show_subtitle'])) {
            $instance['show_subtitle'] = 0;
        }
        asort($contentorder, SORT_NUMERIC);
        foreach ($contentorder as $key => $value) {
            if ($instance['show_' . $key]) {
                $new_sort[] = $key;
            }
        }
        /* @since 09/26/2013 */
        $tax_names = get_object_taxonomies($post_type);
        if (!empty($tax_names) && in_array('category', $tax_names)) {
            $category = $instance['category'];
        } else {
            $category = '';
        }
        $query_args = array('cat' => $instance['category'], 'showposts' => (int) $instance['number_posts'], 'offset' => (int) $instance['offset'], 'nopaging' => 0, 'post_type' => $post_type, 'post_status' => 'publish', XF_STICKY_HANDLING => (bool) $instance['sticky'], 'orderby' => esc_attr($instance['orderby']), 'order' => esc_attr($instance['order']));
        /**
         * exclude the current post_id on is_singular()
         * @since 1.6.3
         * @link https://github.com/inpsyde/xtreme-one/issues/184
         */
        if (is_singular()) {
            $id = get_the_ID();
            if (!!$id) {
                $query_args['post__not_in'] = array($id);
            }
        }
        $r = new WP_Query($query_args);
        if ($r->have_posts()) {
            $i = 0;
            $count = $r->post_count;
            echo $before_widget;
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            while ($r->have_posts()) {
                $r->the_post();
                echo $this->html_before($columns, $i);
                $i++;
                ?>
				<<?php 
                echo $el;
                ?>
 <?php 
                post_class();
                ?>
>
				<?php 
                if (isset($new_sort)) {
                    $c = count($new_sort);
                    for ($y = 0; $y < $c; $y++) {
                        switch ($new_sort[$y]) {
                            case 'thumbnail':
                                if ($instance['as_backgroundimage'] == 0) {
                                    xtreme_post_thumbnail($thumbnail_size, esc_attr($instance['image_alignment']));
                                } else {
                                    xtreme_background_post_thumbnail($thumbnail_size, esc_attr($instance['image_alignment']), esc_html($instance['excerpt_morelink_text']));
                                }
                                break;
                            case 'subtitle':
                                xtreme_widget_post_subtitle($subtag);
                                break;
                            case 'posttitle':
                                if ($html5) {
                                    echo '<header>';
                                }
                                xtreme_widget_post_headline($tag, !$suppress_posttitle_link);
                                if ($html5 && $new_sort[$y + 1] !== 'byline') {
                                    echo '</header>';
                                }
                                break;
                            case 'byline':
                                if (!$html5) {
                                    xtreme_byline();
                                } else {
                                    xtreme_html5_byline();
                                    if ($y !== 0) {
                                        if ($new_sort[$y - 1] == 'posttitle') {
                                            echo '</header>';
                                        }
                                    }
                                }
                                break;
                            case 'content':
                                if ($instance['wrap_content'] == 1) {
                                    echo '<div class="entry-content">';
                                }
                                switch ($instance['content_type']) {
                                    case 'xtreme_excerpt':
                                        $excerpt_length = esc_attr($instance['excerpt_length']);
                                        $excerpt_more_text = esc_html($instance['excerpt_morelink_text']);
                                        $excerpt_more = esc_html($instance['excerpt_more']);
                                        $excerpt_show_tags = isset($instance['excerpt_show_tags']);
                                        xtreme_excerpt($excerpt_length, $excerpt_more_text, $excerpt_more, true, $excerpt_show_tags);
                                        break;
                                    case 'excerpt':
                                        the_excerpt();
                                        echo " <p><span class='read-more'><a href='" . get_permalink() . "' title='" . __('Read more about', XF_TEXTDOMAIN) . ' ' . esc_attr(get_the_title()) . "'>" . esc_html($instance['excerpt_morelink_text']) . "</a></span></p>";
                                        break;
                                    case 'content':
                                        the_content();
                                        break;
                                }
                                if ($instance['wrap_content'] == 1) {
                                    echo '</div>';
                                }
                                break;
                        }
                    }
                    echo '</' . $el . '>';
                    echo $this->html_after($columns, $i);
                }
            }
            wp_reset_query();
            if ($count < (int) $instance['number_posts']) {
                while ($count < (int) $instance['number_posts']) {
                    $count++;
                    echo $this->html_before($columns, $count);
                    echo "&nbsp;";
                    echo $this->html_after($columns, $count);
                }
            }
            echo $after_widget;
        }
    }