/**
     * Front-end display of widget.
     *
     * @see WP_Widget::widget()
     *
     * @param array $args     Widget arguments.
     * @param array $instance Saved values from database.
     */
    function widget($args, $instance)
    {
        // Set vars for widget usage
        $title = isset($instance['title']) ? $instance['title'] : '';
        $title = apply_filters('widget_title', $title);
        $post_type = isset($instance['post_type']) ? $instance['post_type'] : '';
        $taxonomy = isset($instance['taxonomy']) ? $instance['taxonomy'] : '';
        $terms = isset($instance['terms']) ? $instance['terms'] : '';
        $number = isset($instance['number']) ? $instance['number'] : '';
        $order = isset($instance['order']) ? $instance['order'] : '';
        $columns = isset($instance['columns']) ? $instance['columns'] : '3';
        $img_hover = isset($instance['img_hover']) ? $instance['img_hover'] : '';
        $img_size = isset($instance['img_size']) ? $instance['img_size'] : 'wpex_custom';
        $img_height = !empty($instance['img_height']) ? intval($instance['img_height']) : '';
        $img_width = !empty($instance['img_width']) ? intval($instance['img_width']) : '';
        $img_size = $img_width || $img_height ? 'wpex_custom' : $img_size;
        $exclude = is_singular() ? array(get_the_ID()) : NULL;
        // Sanitize terms
        if ($terms) {
            $terms = str_replace(', ', ',', $terms);
            $terms = explode(',', $terms);
        }
        // Before widget WP hook
        echo $args['before_widget'];
        // Display title if defined
        if ($title) {
            echo $args['before_title'] . $title . $args['after_title'];
        }
        ?>

		<ul class="wpex-recent-posts-thumb-grid wpex-row clr">

			<?php 
        // Query args
        $query_args = array('post_type' => $post_type, 'posts_per_page' => $number, 'orderby' => $order, 'meta_key' => '_thumbnail_id', 'post__not_in' => $exclude, 'no_found_rows' => true);
        // Taxonomy args
        if (!empty($taxonomy) && !empty($terms)) {
            $query_args['tax_query'] = array(array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $terms));
        }
        // Query posts
        $my_query = new WP_Query($query_args);
        ?>
			
			<?php 
        // Set post counter variable
        $count = 0;
        ?>

			<?php 
        // Loop through posts
        while ($my_query->have_posts()) {
            $my_query->the_post();
            ?>

				<?php 
            // Add to counter variable
            $count++;
            ?>
				
				<?php 
            // Get post thumbnail
            $thumbnail = wpex_get_post_thumbnail(array('size' => $img_size, 'width' => $img_width, 'height' => $img_height, 'alt' => wpex_get_esc_title()));
            ?>

				<?php 
            // Get hover classes
            if ($img_hover) {
                $hover_classes = ' class="' . wpex_image_hover_classes($img_hover) . '"';
            } else {
                $hover_classes = '';
            }
            ?>

				<li class="<?php 
            echo wpex_grid_class($columns);
            ?>
 nr-col col-<?php 
            echo $count;
            ?>
">
					<a href="<?php 
            wpex_permalink();
            ?>
" title="<?php 
            wpex_esc_title();
            ?>
"<?php 
            echo $hover_classes;
            ?>
><?php 
            echo $thumbnail;
            ?>
</a>
				</li>

				<?php 
            // Reset counter to clear floats
            if ($count == $columns) {
                $count = '0';
            }
            ?>

			<?php 
            // End loop
        }
        ?>

			<?php 
        // Reset global query post data
        wp_reset_postdata();
        ?>

		</ul>

		<?php 
        // After widget WP hook
        echo $args['after_widget'];
        ?>
		
	<?php 
    }
Example #2
0
    /**
     * Front-end display of widget.
     *
     * @see WP_Widget::widget()
     *
     * @param array $args     Widget arguments.
     * @param array $instance Saved values from database.
     */
    public function widget($args, $instance)
    {
        // Parse instance
        extract(wp_parse_args($instance, $this->defaults));
        $img_hover_classes = wpex_image_hover_classes($img_hover);
        // Apply filters to the title
        $title = apply_filters('widget_title', $title, $instance, $this->id_base);
        // Before widget WP hook
        echo $args['before_widget'];
        // Display title if defined
        if ($title) {
            echo $args['before_title'] . $title . $args['after_title'];
        }
        ?>

		<ul class="wpex-recent-posts-thumb-grid wpex-row clr">

			<?php 
        // Query args
        $query_args = array('post_type' => $post_type, 'posts_per_page' => $number, 'meta_key' => '_thumbnail_id', 'no_found_rows' => true);
        // Order params - needs FALLBACK don't ever edit!
        if (!empty($orderby)) {
            $query_args['order'] = $order;
            $query_args['orderby'] = $orderby;
        } else {
            $query_args['orderby'] = $order;
            // THIS IS THE FALLBACK
        }
        // Taxonomy args
        if (!empty($taxonomy) && !empty($terms)) {
            // Sanitize terms and convert to array
            $terms = str_replace(', ', ',', $terms);
            $terms = explode(',', $terms);
            // Add to query arg
            $query_args['tax_query'] = array(array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $terms));
        }
        // Exclude current post
        if (is_singular()) {
            $query_args['post__not_in'] = array(get_the_ID());
        }
        // Query posts
        $wpex_query = new WP_Query($query_args);
        // Set post counter variable
        $count = 0;
        // Loop through posts
        while ($wpex_query->have_posts()) {
            $wpex_query->the_post();
            ?>

				<?php 
            // Add to counter variable
            $count++;
            ?>

				<li class="<?php 
            echo wpex_grid_class($columns);
            ?>
 nr-col col-<?php 
            echo esc_attr($count);
            ?>
">
					<a href="<?php 
            wpex_permalink();
            ?>
" title="<?php 
            wpex_esc_title();
            ?>
"<?php 
            if ($img_hover_classes) {
                echo ' class="' . esc_attr($img_hover_classes) . '"';
            }
            ?>
>
						<?php 
            wpex_post_thumbnail(array('size' => $img_size, 'width' => $img_width, 'height' => $img_height, 'alt' => wpex_get_esc_title()));
            ?>
					</a>
				</li>

				<?php 
            // Reset counter to clear floats
            if ($count == $columns) {
                $count = '0';
            }
            ?>

			<?php 
            // End loop
        }
        ?>

			<?php 
        // Reset global query post data
        wp_reset_postdata();
        ?>

		</ul>

		<?php 
        // After widget WP hook
        echo $args['after_widget'];
        ?>
		
	<?php 
    }
Example #3
0
}
$classes = implode(' ', $classes);
?>

<div class="<?php 
echo $classes;
?>
">

	<?php 
// Open link around staff members if enabled
if (wpex_get_mod('staff_links_enable', true)) {
    ?>

		<a href="<?php 
    wpex_permalink();
    ?>
" title="<?php 
    wpex_esc_title();
    ?>
" rel="bookmark">

	<?php 
}
?>

		<?php 
echo $thumbnail;
?>

		<?php 
Example #4
0
    function vcex_blog_grid_shortcode($atts)
    {
        extract(shortcode_atts(array('unique_id' => '', 'term_slug' => '', 'include_categories' => '', 'exclude_categories' => '', 'posts_per_page' => '4', 'grid_style' => 'fit_columns', 'columns' => '3', 'order' => 'DESC', 'orderby' => 'date', 'filter' => 'false', 'masonry_layout_mode' => '', 'filter_speed' => '', 'center_filter' => '', 'thumbnail_link' => 'post', 'entry_media' => "true", 'img_width' => '9999', 'img_height' => '9999', 'thumb_link' => 'post', 'img_filter' => '', 'title' => 'true', 'date' => 'true', 'excerpt' => 'true', 'excerpt_length' => '15', 'custom_excerpt_trim' => 'true', 'read_more' => 'false', 'read_more_text' => __('read more', 'wpex'), 'pagination' => 'false', 'filter_content' => 'false', 'offset' => 0, 'taxonomy' => '', 'terms' => '', 'all_text' => __('All', 'wpex'), 'featured_video' => 'true', 'url_target' => '_self', 'date_color' => '', 'content_heading_margin' => '', 'content_background' => '', 'content_margin' => '', 'content_font_size' => '', 'content_padding' => '', 'content_border' => '', 'content_color' => '', 'content_opacity' => '', 'content_heading_color' => '', 'content_heading_size' => '', 'content_alignment' => '', 'readmore_background' => '', 'readmore_color' => '', 'equal_heights_grid' => '', 'single_column_style' => ''), $atts));
        // Turn output buffer on
        ob_start();
        // Get global $post var
        global $post;
        // Include categories
        $include_categories = '' != $include_categories ? $include_categories : $term_slug;
        $include_categories = 'all' == $include_categories ? '' : $include_categories;
        $filter_cats_include = '';
        if ($include_categories) {
            $include_categories = explode(',', $include_categories);
            $filter_cats_include = array();
            foreach ($include_categories as $key) {
                $key = get_term_by('slug', $key, 'category');
                $filter_cats_include[] = $key->term_id;
            }
        }
        // Exclude categories
        $filter_cats_exclude = '';
        if ($exclude_categories) {
            $exclude_categories = explode(',', $exclude_categories);
            if (!empty($exclude_categories) && is_array($exclude_categories)) {
                $filter_cats_exclude = array();
                foreach ($exclude_categories as $key) {
                    $key = get_term_by('slug', $key, 'category');
                    $filter_cats_exclude[] = $key->term_id;
                }
                $exclude_categories = array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $exclude_categories, 'operator' => 'NOT IN');
            } else {
                $exclude_categories = '';
            }
        }
        // Start Tax Query
        if (!empty($include_categories) && is_array($include_categories)) {
            $include_categories = array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $include_categories, 'operator' => 'IN');
        } else {
            $include_categories = '';
        }
        // Pagination var
        $paged = NULL;
        $no_found_rows = true;
        if ('true' == $pagination) {
            global $paged;
            $paged = get_query_var('paged') ? get_query_var('paged') : 1;
            $no_found_rows = false;
        }
        // The Query
        $wpex_query = new WP_Query(array('post_type' => 'post', 'posts_per_page' => $posts_per_page, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby, 'filter_content' => $filter_content, 'paged' => $paged, 'tax_query' => array('relation' => 'AND', $include_categories, $exclude_categories), 'no_found_rows' => $no_found_rows));
        //Output posts
        if ($wpex_query->posts) {
            // Custom excerpts trim
            $custom_excerpt_trim = 'true' == $custom_excerpt_trim ? true : false;
            // Image hard crop
            if ('9999' == $img_height) {
                $img_crop = false;
            } else {
                $img_crop = true;
            }
            // Equal heights class
            if ('1' != $columns && ('fit_columns' == $grid_style && 'true' == $equal_heights_grid)) {
                $equal_heights_grid = true;
            } else {
                $equal_heights_grid = false;
            }
            // Is Isotope var
            if ('true' == $filter || 'masonry' == $grid_style) {
                $is_isotope = true;
            } else {
                $is_isotope = false;
            }
            // No need for masonry if not enough columns and filter is disabled
            if ('true' != $filter && 'masonry' == $grid_style) {
                $post_count = count($wpex_query->posts);
                if ($post_count <= $columns) {
                    $is_isotope = false;
                }
            }
            // Output script for inline JS for the Visual composer front-end builder
            if ($is_isotope) {
                vcex_front_end_grid_js('isotope');
            }
            // Display filter links
            if ($filter == 'true') {
                $terms = get_terms('category', array('include' => $filter_cats_include, 'exclude' => $filter_cats_exclude));
                if ($terms && count($terms) > '1') {
                    $center_filter = 'yes' == $center_filter ? 'center' : '';
                    ?>
					<ul class="vcex-blog-filter vcex-filter-links <?php 
                    echo $center_filter;
                    ?>
 clr">
						<li class="active"><a href="#" data-filter="*"><span><?php 
                    echo $all_text;
                    ?>
</span></a></li>
						<?php 
                    foreach ($terms as $term) {
                        ?>
							<li><a href="#" data-filter=".cat-<?php 
                        echo $term->term_id;
                        ?>
"><?php 
                        echo $term->name;
                        ?>
</a></li>
						<?php 
                    }
                    ?>
					</ul><!-- .vcex-blog-filter -->
				<?php 
                }
                ?>
			<?php 
            }
            // Content Design
            $content_style = '';
            if ($content_background) {
                $content_style .= 'background:' . $content_background . ';';
            }
            if ($content_padding) {
                $content_style .= 'padding:' . $content_padding . ';';
            }
            if ($content_margin) {
                $content_style .= 'margin:' . $content_margin . ';';
            }
            if ($content_border) {
                $content_style .= 'border:' . $content_border . ';';
            }
            if ($content_font_size) {
                $content_style .= 'font-size:' . $content_font_size . ';';
            }
            if ($content_color) {
                $content_style .= 'color:' . $content_color . ';';
            }
            if ($content_opacity) {
                $content_style .= 'opacity:' . $content_opacity . ';';
            }
            if ($content_alignment) {
                $content_style .= 'text-align:' . $content_alignment . ';';
            }
            if ($content_style) {
                $content_style = 'style="' . $content_style . '"';
            }
            // Heading Design
            $heading_style = '';
            if ($content_heading_margin) {
                $heading_style .= 'margin:' . $content_heading_margin . ';';
            }
            if ($content_heading_size) {
                $heading_style .= 'font-size:' . $content_heading_size . ';';
            }
            if ($content_heading_color) {
                $heading_style .= 'color:' . $content_heading_color . ';';
            }
            if ($heading_style) {
                $heading_style = 'style="' . $heading_style . '"';
            }
            // Readmore design
            if ('true' == $read_more) {
                $readmore_style = '';
                if ($readmore_background) {
                    $readmore_style .= 'background:' . $readmore_background . ';';
                }
                if ($readmore_color) {
                    $readmore_style .= 'color:' . $readmore_color . ';';
                }
                if ($readmore_style) {
                    $readmore_style = 'style="' . $readmore_style . '"';
                }
            }
            // Date design
            $date_style = '';
            if ('true' == $date) {
                if ($date_color) {
                    $date_style .= 'color:' . $date_color . ';';
                }
                if ($date_style) {
                    $date_style = 'style="' . $date_style . '"';
                }
            }
            // Wrap classes
            $wrap_classes = 'wpex-row vcex-blog-grid clr';
            if ($is_isotope) {
                $wrap_classes .= ' vcex-isotope-grid';
            }
            if ('left_thumbs' == $single_column_style) {
                $wrap_classes .= ' left-thumbs';
            }
            // Unique ID
            if ($unique_id) {
                $unique_id = ' id="' . $unique_id . '"';
            }
            // Data
            $data = '';
            if ($is_isotope && 'true' == $filter) {
                if ($masonry_layout_mode) {
                    $data .= ' data-layout-mode="' . $masonry_layout_mode . '"';
                }
                if ($filter_speed) {
                    $data .= ' data-transition-duration="' . $filter_speed . '"';
                }
            }
            ?>
	
			<div class="<?php 
            echo $wrap_classes;
            ?>
"<?php 
            echo $unique_id . $data;
            ?>
>
				<?php 
            // Define counter var to clear floats
            $count = $count_all = '';
            // Loop through posts
            foreach ($wpex_query->posts as $post) {
                setup_postdata($post);
                // Open match-height-row div for equal heights
                if ($equal_heights_grid && !$is_isotope) {
                    if (0 == $count) {
                        ?>
							<div class="match-height-row clr">
						<?php 
                    }
                    $count_all++;
                }
                // Post Vars
                $post_id = $post->ID;
                $format = get_post_format($post_id);
                $post_title = get_the_title();
                $post_title_esc = esc_attr(the_title_attribute('echo=0'));
                $link = get_permalink();
                // Counter
                $count++;
                // Link format tweaks
                if ('link' == $format) {
                    $link = wpex_permalink();
                    $url_target = '_blank';
                }
                // Get video
                if ('video' == $format) {
                    $video_url = get_post_meta($post_id, 'wpex_post_oembed', true);
                }
                // Entry Classes
                $entry_classes = 'vcex-blog-entry col';
                $entry_classes .= ' col-' . $count;
                $entry_classes .= ' span_1_of_' . $columns;
                if ($is_isotope) {
                    $entry_classes .= ' vcex-isotope-entry';
                }
                // Create a list of terms to add as classes to the entry
                if ($post_terms = get_the_terms($post, 'category')) {
                    foreach ($post_terms as $post_term) {
                        $entry_classes .= ' cat-' . $post_term->term_id;
                    }
                }
                if ("false" == $entry_media) {
                    $entry_classes .= ' vcex-blog-no-media-entry';
                }
                ?>
					<article id="#post-<?php 
                the_ID();
                ?>
" class="<?php 
                echo $entry_classes;
                ?>
">
						<?php 
                if ("true" == $entry_media) {
                    ?>
							<?php 
                    $img_filter_class = $img_filter ? 'vcex-' . $img_filter : '';
                    ?>
							<?php 
                    if ("video" == $format && 'true' == $featured_video && $video_url) {
                        ?>
								<div class="vcex-blog-entry-media">
									<div class="vcex-video-wrap">
										<?php 
                        echo wp_oembed_get($video_url);
                        ?>
									</div>
								</div><!-- .vcex-blog-entry-media -->
							<?php 
                    } elseif (has_post_thumbnail()) {
                        ?>
								<div class="vcex-blog-entry-media <?php 
                        echo $img_filter_class;
                        ?>
">
									<?php 
                        if ($thumb_link == 'post' || $thumb_link == 'lightbox') {
                            ?>
										<?php 
                            // Post links
                            if ($thumb_link == 'post') {
                                ?>
											<a href="<?php 
                                echo $link;
                                ?>
" title="<?php 
                                echo $post_title_esc;
                                ?>
" target="<?php 
                                echo $url_target;
                                ?>
">
										<?php 
                            }
                            ?>
										<?php 
                            // Lightbox Links
                            if ($thumb_link == 'lightbox') {
                                ?>
											<?php 
                                // Video Lightbox
                                if ('video' == $format) {
                                    ?>
												<a href="<?php 
                                    echo $video_url;
                                    ?>
" title="<?php 
                                    echo $post_title_esc;
                                    ?>
" class="wpex-lightbox-video">
											<?php 
                                } else {
                                    ?>
												<a href="<?php 
                                    echo wp_get_attachment_url(get_post_thumbnail_id());
                                    ?>
" title="<?php 
                                    echo $post_title_esc;
                                    ?>
" class="wpex-lightbox">
											<?php 
                                }
                                ?>
										<?php 
                            }
                            ?>
									<?php 
                        }
                        // Get cropped image array and display image
                        $cropped_img = wpex_image_resize(wp_get_attachment_url(get_post_thumbnail_id()), intval($img_width), intval($img_height), $img_crop, 'array');
                        ?>
										<img src="<?php 
                        echo $cropped_img['url'];
                        ?>
" alt="<?php 
                        the_title();
                        ?>
" class="vcex-blog-entry-img" height="<?php 
                        echo $cropped_img['height'];
                        ?>
" width="<?php 
                        echo $cropped_img['width'];
                        ?>
" />
									<?php 
                        if ($thumb_link == 'post' || $thumb_link == 'lightbox') {
                            ?>
										</a>
									<?php 
                        }
                        ?>
								</div><!-- .blog-entry-media -->
							<?php 
                    }
                    ?>
						<?php 
                }
                ?>
						<?php 
                // Display entry details if the title or excerpt are enabled
                if ('true' == $title || 'true' == $excerpt) {
                    ?>
							<div class="vcex-blog-entry-details clr" <?php 
                    echo $content_style;
                    ?>
>
								<?php 
                    // Equal height div
                    if ($equal_heights_grid && !$is_isotope) {
                        ?>
								<div class="match-height-content">
								<?php 
                    }
                    // Post Title
                    if ($title == 'true') {
                        ?>
									<h2 class="vcex-blog-entry-title" <?php 
                        echo $heading_style;
                        ?>
>
										<a href="<?php 
                        echo $link;
                        ?>
" title="<?php 
                        echo $post_title_esc;
                        ?>
" target="<?php 
                        echo $url_target;
                        ?>
" <?php 
                        echo $heading_style;
                        ?>
>
											<?php 
                        the_title();
                        ?>
										</a>
									</h2>
								<?php 
                    }
                    // Post Date
                    if ($date == 'true') {
                        ?>
									<div class="vcex-blog-entry-date" <?php 
                        echo $date_style;
                        ?>
><?php 
                        echo get_the_date();
                        ?>
</div>
								<?php 
                    }
                    // Excerpt
                    if ('true' == $excerpt || 'true' == $read_more) {
                        if ('true' != $excerpt) {
                            $excerpt_length = '0';
                        }
                        ?>
									<div class="vcex-blog-entry-excerpt clr">
										<?php 
                        // Show full content
                        if ('9999' == $excerpt_length) {
                            the_content();
                        } else {
                            // Custom Excerpt
                            $excerpt_array = array('post_id' => $post_id, 'length' => intval($excerpt_length), 'trim_custom_excerpts' => $custom_excerpt_trim);
                            vcex_excerpt($excerpt_array);
                        }
                        // Read more
                        if ('true' == $read_more) {
                            if ('link' == $format) {
                                $read_more_text = __('Visit Website', 'wpex');
                            }
                            ?>
											<a href="<?php 
                            echo $link;
                            ?>
" title="<?php 
                            echo $read_more_text;
                            ?>
" rel="bookmark" class="vcex-readmore theme-button" target="<?php 
                            echo $url_target;
                            ?>
" <?php 
                            echo $readmore_style;
                            ?>
>
												<?php 
                            echo $read_more_text;
                            ?>
 <span class="vcex-readmore-rarr"><?php 
                            echo wpex_element('rarr');
                            ?>
</span>
											</a>
										<?php 
                        }
                        ?>
									</div>
								<?php 
                    }
                    // Close Equal height div
                    if ($equal_heights_grid && !$is_isotope) {
                        ?>
								</div>
								<?php 
                    }
                    ?>
							</div><!-- .blog-entry-details -->
						<?php 
                }
                ?>
					</article><!-- .blog-entry -->
				<?php 
                // Reset counter
                if ($count == $columns) {
                    // Close equal height row
                    if ($equal_heights_grid && !$is_isotope) {
                        echo '</div><!-- .match-height-row -->';
                    }
                    $count = '0';
                }
                // End foreach
            }
            // Make sure match-height-row is closed
            if ($equal_heights_grid && !$is_isotope) {
                if ('4' == $columns && $count_all % 4 != 0) {
                    echo '</div><!-- .match-height-row -->';
                }
                if ('3' == $columns && $count_all % 3 != 0) {
                    echo '</div><!-- .match-height-row -->';
                }
                if ('2' == $columns && $count_all % 2 != 0) {
                    echo '</div><!-- .match-height-row -->';
                }
            }
            ?>
			</div><!-- .vcex-blog-grid -->
			
			<?php 
            // Paginate Posts
            if ('true' == $pagination) {
                wpex_pagination($wpex_query);
            }
            // End has posts check
        }
        // Reset the WP query
        wp_reset_postdata();
        // Return outbut buffer
        return ob_get_clean();
    }
Example #5
0
        /**
         * Front-end display of widget.
         *
         * @see WP_Widget::widget()
         * @since 1.0.0
         *
         *
         * @param array $args     Widget arguments.
         * @param array $instance Saved values from database.
         */
        public function widget($args, $instance)
        {
            // Sanitize args
            $title = isset($instance['title']) ? apply_filters('widget_title', $instance['title']) : '';
            $number = isset($instance['number']) ? $instance['number'] : '5';
            $order = isset($instance['order']) ? $instance['order'] : 'DESC';
            $orderby = isset($instance['orderby']) ? $instance['orderby'] : 'date';
            $category = isset($instance['category']) ? $instance['category'] : 'all';
            $exclude = is_singular() ? array(get_the_ID()) : NULL;
            // Before Widget Hook
            echo $args['before_widget'];
            // Title
            if ($title) {
                echo $args['before_title'] . $title . $args['after_title'];
            }
            // Category
            if (!empty($category) && 'all' != $category) {
                $taxonomy = array(array('taxonomy' => 'category', 'field' => 'id', 'terms' => $category));
            } else {
                $taxonomy = NUll;
            }
            // Query Posts
            global $post;
            $wpex_query = new WP_Query(array('post_type' => 'post', 'posts_per_page' => $number, 'orderby' => $orderby, 'order' => $order, 'no_found_rows' => true, 'post__not_in' => $exclude, 'tax_query' => $taxonomy, 'ignore_sticky_posts' => 1));
            // Loop through posts
            if ($wpex_query->have_posts()) {
                ?>

					<ul class="widget-recent-posts-icons clr">

						<?php 
                foreach ($wpex_query->posts as $post) {
                    setup_postdata($post);
                    ?>

							<li class="clr">
								<a href="<?php 
                    esc_url(wpex_permalink());
                    ?>
" title="<?php 
                    wpex_esc_title();
                    ?>
"><span class="<?php 
                    esc_attr(wpex_post_format_icon());
                    ?>
"></span><?php 
                    the_title();
                    ?>
</a>
							</li>

						<?php 
                }
                ?>

					</ul>

				<?php 
            }
            ?>

			<?php 
            // Reset post data
            wp_reset_postdata();
            ?>

			<?php 
            // After widget hook
            echo $args['after_widget'];
            ?>

		<?php 
        }
Example #6
0
    /**
     * Front-end display of widget.
     *
     * @see WP_Widget::widget()
     *
     * @param array $args     Widget arguments.
     * @param array $instance Saved values from database.
     */
    public function widget($args, $instance)
    {
        // Parse instance
        extract(wp_parse_args($instance, $this->defaults));
        // Apply filters to the title
        $title = isset($instance['title']) ? apply_filters('widget_title', $instance['title']) : '';
        // Before widget WP hook
        echo $args['before_widget'];
        // Display title if defined
        if ($title) {
            echo $args['before_title'] . $title . $args['after_title'];
        }
        ?>

		<ul class="wpex-widget-recent-posts wpex-clr style-<?php 
        echo esc_attr($style);
        ?>
">

			<?php 
        // Query args
        $query_args = array('post_type' => $post_type, 'posts_per_page' => $number, 'meta_key' => '_thumbnail_id', 'no_found_rows' => true);
        // Order params - needs FALLBACK don't ever edit!
        if (!empty($orderby)) {
            $query_args['order'] = $order;
            $query_args['orderby'] = $orderby;
        } else {
            $query_args['orderby'] = $order;
            // THIS IS THE FALLBACK
        }
        // Taxonomy args
        if (!empty($taxonomy) && !empty($terms)) {
            // Sanitize terms and convert to array
            $terms = str_replace(', ', ',', $terms);
            $terms = explode(',', $terms);
            // Add to query arg
            $query_args['tax_query'] = array(array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $terms));
        }
        // Exclude current post
        if (is_singular()) {
            $query_args['post__not_in'] = array(get_the_ID());
        }
        // Query posts
        $wpex_query = new WP_Query($query_args);
        // If there are posts loop through them
        if ($wpex_query->have_posts()) {
            // Loop through posts
            while ($wpex_query->have_posts()) {
                $wpex_query->the_post();
                ?>

					<?php 
                // Get hover classes
                if ($img_hover) {
                    $hover_classes = ' ' . wpex_image_hover_classes($img_hover);
                } else {
                    $hover_classes = '';
                }
                ?>

					<li class="wpex-widget-recent-posts-li clr">

						<?php 
                if (has_post_thumbnail()) {
                    ?>
							<a href="<?php 
                    wpex_permalink();
                    ?>
" title="<?php 
                    wpex_esc_title();
                    ?>
" class="wpex-widget-recent-posts-thumbnail<?php 
                    echo esc_attr($hover_classes);
                    ?>
">
								<?php 
                    wpex_post_thumbnail(array('size' => $img_size, 'width' => $img_width, 'height' => $img_height, 'alt' => wpex_get_esc_title()));
                    ?>
							</a>
						<?php 
                }
                ?>

						<a href="<?php 
                wpex_permalink();
                ?>
" title="<?php 
                wpex_esc_title();
                ?>
" class="wpex-widget-recent-posts-title"><?php 
                the_title();
                ?>
</a>

						<?php 
                // Display date if enabled
                if ('1' != $date) {
                    ?>

							<div class="wpex-widget-recent-posts-date">
								<?php 
                    echo get_the_date();
                    ?>
							</div><!-- .wpex-widget-recent-posts-date -->

						<?php 
                }
                ?>

					</li><!-- .wpex-widget-recent-posts-li -->

				<?php 
            }
            ?>

			<?php 
        }
        ?>

		</ul><!-- .wpex-widget-recent-posts -->

		<?php 
        wp_reset_postdata();
        ?>
		
		<?php 
        // After widget WordPress hook
        echo $args['after_widget'];
    }
Example #7
0
    exit;
}
// Return if there isn't any thumbnail
if (!has_post_thumbnail()) {
    return;
}
// Get cropped featured image
$image = wpex_image('array');
// Get title
$esc_title = esc_attr(the_title_attribute('echo=0'));
?>

<div class="blog-entry-media clr">

	<a href="<?php 
echo wpex_permalink(get_the_ID());
?>
" title="<?php 
echo $esc_title;
?>
" rel="bookmark" class="blog-entry-media-link <?php 
wpex_img_animation_classes();
?>
" target="_blank">
		<img src="<?php 
echo $image['url'];
?>
" alt="<?php 
echo $esc_title;
?>
" width="<?php 
Example #8
0
 *
 * @package		Total
 * @subpackage	Templates
 * @author		Alexander Clarke
 * @copyright	Copyright (c) 2014, Symple Workz LLC
 * @link		http://www.wpexplorer.com
 * @since		Total 1.0.0
 */
?>

<?php 
// Redirect link format if custom link defined
if (get_post_meta(get_the_ID(), 'wpex_post_link', true)) {
    ?>
	<?php 
    wp_redirect(wpex_permalink(), 301);
}
?>

<?php 
get_header();
?>

	<?php 
while (have_posts()) {
    the_post();
    ?>

		<?php 
    if ('post' == get_post_type()) {
        ?>
    /**
     * Front-end display of widget.
     *
     * @see WP_Widget::widget()
     *
     * @param array $args     Widget arguments.
     * @param array $instance Saved values from database.
     */
    function widget($args, $instance)
    {
        // Set vars
        $title = isset($instance['title']) ? apply_filters('widget_title', $instance['title']) : __('Recent Posts', 'wpex');
        $number = isset($instance['number']) ? $instance['number'] : '3';
        $style = isset($instance['style']) ? $instance['style'] : 'default';
        $order = isset($instance['order']) ? $instance['order'] : '';
        $date = isset($instance['date']) ? $instance['date'] : '';
        $post_type = isset($instance['post_type']) ? $instance['post_type'] : '';
        $taxonomy = isset($instance['taxonomy']) ? $instance['taxonomy'] : '';
        $terms = isset($instance['terms']) ? $instance['terms'] : '';
        $img_hover = isset($instance['img_hover']) ? $instance['img_hover'] : '';
        $img_size = isset($instance['img_size']) ? $instance['img_size'] : 'wpex_custom';
        $img_height = !empty($instance['img_height']) ? intval($instance['img_height']) : '';
        $img_width = !empty($instance['img_width']) ? intval($instance['img_width']) : '';
        $img_size = $img_width || $img_height ? 'wpex_custom' : $img_size;
        $exclude = is_singular() ? array(get_the_ID()) : NULL;
        // Sanitize terms
        if ($terms) {
            $terms = str_replace(', ', ',', $terms);
            $terms = explode(',', $terms);
        }
        // Before widget WP hook
        echo $args['before_widget'];
        // Display title if defined
        if ($title) {
            echo $args['before_title'] . $title . $args['after_title'];
        }
        ?>

		<ul class="wpex-widget-recent-posts clr style-<?php 
        echo $style;
        ?>
">

			<?php 
        // Query args
        $query_args = array('post_type' => $post_type, 'posts_per_page' => $number, 'orderby' => $order, 'post__not_in' => $exclude, 'meta_key' => '_thumbnail_id', 'no_found_rows' => true);
        // Taxonomy args
        if (!empty($taxonomy) && !empty($terms)) {
            $query_args['tax_query'] = array(array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $terms));
        }
        // Query posts
        $my_query = new WP_Query($query_args);
        // If there are posts loop through them
        if ($my_query->have_posts()) {
            // Loop through posts
            while ($my_query->have_posts()) {
                $my_query->the_post();
                ?>
				
					<?php 
                // Get post thumbnail
                $thumbnail = wpex_get_post_thumbnail(array('size' => $img_size, 'width' => $img_width, 'height' => $img_height, 'alt' => wpex_get_esc_title()));
                ?>

					<?php 
                // Get hover classes
                if ($img_hover) {
                    $hover_classes = ' ' . wpex_image_hover_classes($img_hover);
                } else {
                    $hover_classes = '';
                }
                ?>

					<li class="wpex-widget-recent-posts-li clr">

						<?php 
                if ($thumbnail) {
                    ?>
							<a href="<?php 
                    wpex_permalink();
                    ?>
" title="<?php 
                    wpex_esc_title();
                    ?>
" class="wpex-widget-recent-posts-thumbnail<?php 
                    echo $hover_classes;
                    ?>
"><?php 
                    echo $thumbnail;
                    ?>
</a>
						<?php 
                }
                ?>

						<a href="<?php 
                wpex_permalink();
                ?>
" title="<?php 
                wpex_esc_title();
                ?>
" class="wpex-widget-recent-posts-title"><?php 
                the_title();
                ?>
</a>

						<?php 
                // Display date if enabled
                if ('1' != $date) {
                    ?>

							<div class="wpex-widget-recent-posts-date">
								<?php 
                    echo get_the_date();
                    ?>
							</div><!-- .wpex-widget-recent-posts-date -->

						<?php 
                }
                ?>

					</li><!-- .wpex-widget-recent-posts-li -->

				<?php 
            }
            ?>

			<?php 
        }
        ?>

		</ul><!-- .wpex-widget-recent-posts -->

		<?php 
        wp_reset_postdata();
        ?>
		
		<?php 
        // After widget WordPress hook
        echo $args['after_widget'];
    }
Example #10
0
    exit;
}
// Get post id
$post_id = get_the_ID();
$display_avatar = wpex_post_entry_author_avatar_enabled($post_id);
?>

<header class="clr <?php 
if ($display_avatar) {
    echo 'header-with-avatar';
}
?>
">
	<h2 class="blog-entry-title">
		<a href="<?php 
echo wpex_permalink($post_id);
?>
" title="<?php 
echo esc_attr(the_title_attribute('echo=0'));
?>
" rel="bookmark">
			<?php 
the_title();
?>
		</a>
	</h2>
	<?php 
// Display avatar if enabled
if ($display_avatar) {
    ?>
		<div class="blog-entry-author-avatar">
Example #11
0
$post_id = get_the_ID();
$format = get_post_format($post_id);
$text = get_theme_mod('blog_entry_readmore_text', __('Read More', 'wpex'));
// Button Text
if ('link' == $format) {
    $text = __('Visit Website', 'wpex');
} elseif (!$text) {
    $text = __('Read More', 'wpex');
}
$text = apply_filters('wpex_post_readmore_link_text', $text);
// Output the readmore button
if ('link' == $format) {
    ?>
	<div class="blog-entry-readmore clr">
		<a href="<?php 
    echo wpex_permalink();
    ?>
" class="theme-button" title="<?php 
    echo __('Visit Website', 'wpex');
    ?>
" target="_blank">
			<?php 
    echo $text;
    ?>
<span class="readmore-rarr">&rarr;</span>
		</a>
	</div>
<?php 
} else {
    ?>
	<div class="blog-entry-readmore clr">
Example #12
0
    function vcex_news_shortcode($atts)
    {
        extract(shortcode_atts(array('unique_id' => '', 'post_types' => '', 'term_slug' => 'all', 'include_categories' => '', 'exclude_categories' => '', 'count' => '12', 'grid_columns' => '1', 'order' => 'DESC', 'orderby' => 'date', 'header' => '', 'heading' => 'h3', 'date' => '', 'excerpt_length' => '15', 'read_more' => 'false', 'read_more_text' => __('read more', 'wpex'), 'filter_content' => 'false', 'offset' => 0, 'taxonomy' => '', 'terms' => '', 'css_animation' => '', 'img_width' => '9999', 'img_height' => '9999', 'featured_image' => 'false', 'featured_video' => 'true', 'pagination' => 'false', 'get_posts' => '', 'title' => '', 'title_size' => '', 'url_target' => '_self'), $atts));
        // Turn output buffer on
        ob_start();
        // Get global $post
        global $post;
        // Custom taxonomy only for standard posts
        if ('custom_post_types' != $get_posts) {
            // Post type
            $post_types = array('post');
            // Include categories
            $include_categories = !empty($include_categories) ? $include_categories : $term_slug;
            $include_categories = 'all' == $include_categories ? '' : $include_categories;
            if ($include_categories) {
                $include_categories = explode(',', $include_categories);
            }
            // Exclude categories
            if ($exclude_categories) {
                $exclude_categories = explode(',', $exclude_categories);
                if (!empty($exclude_categories) && is_array($exclude_categories)) {
                    $exclude_categories = array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $exclude_categories, 'operator' => 'NOT IN');
                } else {
                    $exclude_categories = '';
                }
            }
            // Start Tax Query
            if (!empty($include_categories) && is_array($include_categories)) {
                $include_categories = array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $include_categories, 'operator' => 'IN');
            } else {
                $include_categories = '';
            }
        } else {
            // Don't exclude categories for custom post type queries
            $include_categories = $exclude_categories = NULL;
            // Post Types
            $post_types = $post_types ? $post_types : 'post';
            $post_types = explode(',', $post_types);
        }
        // Pagination var
        if ('true' == $pagination) {
            global $paged;
            $paged = get_query_var('paged') ? get_query_var('paged') : 1;
            $no_found_rows = false;
        } else {
            $paged = NULL;
            $no_found_rows = true;
        }
        // The Query
        $vcex_query = new WP_Query(array('post_type' => $post_types, 'posts_per_page' => $count, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby, 'filter_content' => $filter_content, 'no_found_rows' => $no_found_rows, 'paged' => $paged, 'tax_query' => array('relation' => 'AND', $include_categories, $exclude_categories, array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-quote'), 'operator' => 'NOT IN'))));
        $output = '';
        //Output posts
        if ($vcex_query->posts) {
            $unique_id = $unique_id ? ' id="' . $unique_id . '"' : NULL;
            // CSS animations
            $classes = 'vcex-recent-news clr';
            if ('1' != $grid_columns) {
                $classes .= ' wpex-row';
            }
            if ('' != $css_animation) {
                $classes .= ' wpb_animate_when_almost_visible wpb_' . $css_animation . '';
            }
            ?>
			
				<div class="<?php 
            echo $classes;
            ?>
" <?php 
            echo $unique_id;
            ?>
>
				
				<?php 
            // Header
            if ('' != $header) {
                ?>
					<h2 class="vcex-recent-news-header theme-heading">
						<span><?php 
                echo $header;
                ?>
</span>
					</h2>
				<?php 
            }
            ?>
			
				<?php 
            // Loop through posts
            $count = '0';
            foreach ($vcex_query->posts as $post) {
                setup_postdata($post);
                $count++;
                // Post VARS
                $post_id = $post->ID;
                $url = get_permalink($post_id);
                $post_title = get_the_title($post_id);
                $post_excerpt = $post->post_excerpt;
                $post_content = $post->post_content;
                // Get post format
                $format = get_post_format($post_id);
                // Get post video
                if ('true' == $featured_video) {
                    $post_video = get_post_meta($post_id, 'wpex_post_oembed', true);
                }
                // Get permalink
                $link = get_permalink();
                // Link format tweaks
                if ('link' == $format) {
                    $link = wpex_permalink();
                    $url_target = '_blank';
                }
                // Image
                $featured_img_url = wp_get_attachment_url(get_post_thumbnail_id($post_id));
                $img_width = $img_width ? intval($img_width) : '9999';
                $img_height = $img_height ? intval($img_height) : '9999';
                $img_crop = $img_height == '9999' ? false : true;
                $cropped_img = wpex_image_resize($featured_img_url, $img_width, $img_height, $img_crop, 'array');
                ?>

					<?php 
                // Extra rapper for recent news within columns
                if ($grid_columns > '1') {
                    ?>
					<div class="col span_1_of_<?php 
                    echo $grid_columns;
                    ?>
 vcex-recent-news-entry-wrap col-<?php 
                    echo $count;
                    ?>
">
					<?php 
                }
                // Entry classes
                $entry_classes = 'vcex-recent-news-entry clr';
                if ('false' == $date) {
                    $entry_classes .= ' no-left-padding';
                }
                ?>
					<article class="<?php 
                echo $entry_classes;
                ?>
">
						<?php 
                // Date
                if ('false' != $date) {
                    ?>
							<div class="vcex-recent-news-date">
								<span class="day">
									<?php 
                    echo get_the_time('d', $post_id);
                    ?>
								</span>
								<span class="month">
									<?php 
                    echo get_the_time('M', $post_id);
                    ?>
								</span>
							</div>
						<?php 
                }
                ?>
						<div class="vcex-news-entry-details clr">
							<?php 
                // Thumbnail
                if ('true' == $featured_image) {
                    if ('video' == $format && 'true' == $featured_video && $post_video) {
                        ?>
									<div class="vcex-news-entry-video vcex-video-wrap clr">
										<?php 
                        echo wp_oembed_get($post_video);
                        ?>
									</div>
								<?php 
                    } elseif (has_post_thumbnail($post_id)) {
                        ?>
									<div class="vcex-news-entry-thumbnail clr">
										<a href="<?php 
                        echo $link;
                        ?>
" title="<?php 
                        echo $post_title;
                        ?>
" target="<?php 
                        echo $url_target;
                        ?>
">
											<img src="<?php 
                        echo $cropped_img['url'];
                        ?>
" alt="<?php 
                        the_title();
                        ?>
" class="vcex-recent-news-entry-img" height="<?php 
                        echo $cropped_img['height'];
                        ?>
" width="<?php 
                        echo $cropped_img['width'];
                        ?>
" />
										</a>
									</div>
								<?php 
                    }
                    ?>
							<?php 
                }
                ?>
							<?php 
                // Display title unless disabled
                if ('false' != $title) {
                    // Custom title font-size
                    $inline_style = '';
                    if ($title_size) {
                        $inline_style .= 'font-size:' . intval($title_size) . 'px;';
                    }
                    if ($inline_style) {
                        $inline_style = 'style="' . $inline_style . '"';
                    }
                    ?>
							<header class="vcex-recent-news-entry-title">
								<<?php 
                    echo $heading;
                    ?>
 class="vcex-recent-news-entry-title-heading" <?php 
                    echo $inline_style;
                    ?>
>
									<a href="<?php 
                    echo $link;
                    ?>
" title="<?php 
                    $post_title;
                    ?>
" target="<?php 
                    echo $url_target;
                    ?>
">
										<?php 
                    if ('link' == $format) {
                        ?>
											<span><?php 
                        echo _x('Link', 'Link Format Title', 'wpex');
                        ?>
: </span> <?php 
                        the_title();
                        ?>
										<?php 
                    } else {
                        ?>
											<?php 
                        the_title();
                        ?>
										<?php 
                    }
                    ?>
									</a>
								</<?php 
                    echo $heading;
                    ?>
>
							</header><!-- .vcex-recent-news-entry-title -->
							<?php 
                }
                ?>
							<div class="vcex-recent-news-entry-excerpt vcex-clearfix">
								<?php 
                // Excerpts
                $read_more = $read_more == 'true' ? true : false;
                $excerpt_array = array('length' => intval($excerpt_length), 'readmore' => false);
                vcex_excerpt($excerpt_array);
                ?>
								<?php 
                // Read more
                if ('true' == $read_more) {
                    if ('link' == $format) {
                        $read_more_text = __('Visit Website', 'wpex');
                    }
                    ?>
									<a href="<?php 
                    echo $link;
                    ?>
" title="<?php 
                    echo $read_more_text;
                    ?>
" rel="bookmark" class="vcex-readmore theme-button" target="<?php 
                    echo $url_target;
                    ?>
">
										<?php 
                    echo $read_more_text;
                    ?>
 <span class="vcex-readmore-rarr">&rarr;</span>
									</a>
								<?php 
                }
                ?>
							</div><!-- .vcex-recent-news-entry-excerpt -->
						</div><!-- .vcex-recent-news-entry-details -->
					</article><!-- .vcex-recent-news-entry -->
					<?php 
                if ($grid_columns > '1') {
                    ?>
					</div>
					<?php 
                }
                // Reset counter
                if ($count == $grid_columns) {
                    $count = '';
                }
                // End foreach loop
            }
            ?>
				
				</div><!-- .vcex-recent-news -->

				<div class="vcex-recent-news-pagination clr">
					<?php 
            // Paginate Posts
            if ('true' == $pagination) {
                $total = $vcex_query->max_num_pages;
                $big = 999999999;
                // need an unlikely integer
                if ($total > 1) {
                    if (!($current_page = get_query_var('paged'))) {
                        $current_page = 1;
                    }
                    if (get_option('permalink_structure')) {
                        $format = 'page/%#%/';
                    } else {
                        $format = '&paged=%#%';
                    }
                    echo paginate_links(array('base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => $format, 'current' => max(1, get_query_var('paged')), 'total' => $total, 'mid_size' => 2, 'type' => 'list', 'prev_text' => '<i class="fa fa-angle-left"></i>', 'next_text' => '<i class="fa fa-angle-right"></i>'));
                }
            }
            ?>
				</div>
			<?php 
        }
        // End has posts check
        // Set things back to normal
        wp_reset_postdata();
        // Return data
        return ob_get_clean();
    }