Ejemplo n.º 1
0
<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 
// Inside overlay HTML
wpex_overlay('inside_link');
?>
    /**
     * 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 
    }
Ejemplo n.º 3
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 
    }
Ejemplo n.º 4
0
        function wpex_posts_custom_columns($column_name, $id)
        {
            if ($column_name != 'wpex_post_thumbs') {
                return;
            }
            if (has_post_thumbnail($id)) {
                $img_src = wp_get_attachment_image_src(get_post_thumbnail_id($id), 'thumbnail', false);
                if (!empty($img_src[0])) {
                    ?>
						<img src="<?php 
                    echo esc_url($img_src[0]);
                    ?>
" alt="<?php 
                    wpex_esc_title();
                    ?>
" style="max-width:100%;max-height:90px;" />
					<?php 
                }
            } else {
                echo '&mdash;';
            }
        }
Ejemplo n.º 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 
        }
Ejemplo n.º 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'];
    }
    /**
     * 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'];
    }