Ejemplo n.º 1
0
    /**
     * Display widget content.
     *
     * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
     * @param array $instance The settings for the particular instance of the widget
     */
    function widget($args, $instance)
    {
        global $wp_query, $calibrefx;
        extract($args);
        $instance = wp_parse_args((array) $instance, $this->defaults);
        echo $before_widget;
        if (!empty($instance['title'])) {
            echo $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title;
        }
        $query = new WP_Query(array('posts_per_page' => $instance['num_posts'], 'orderby' => 'date', 'order' => 'DESC', 'ignore_sticky_posts' => true));
        $no_post_thumbnail = apply_filters('no_thumbnail_image_url', CALIBREFX_IMAGES_URL . '/no-image.jpg');
        echo '<ul class="list-latest-posts">';
        if ($query->have_posts()) {
            while ($query->have_posts()) {
                $query->the_post();
                $img = calibrefx_get_image(array('format' => 'html', 'size' => $instance['image_size']));
                $img = !empty($img) ? $img : '<img src="' . $no_post_thumbnail . '" />';
                $date_format = get_option('date_format');
                $item_class = apply_filters('calibrefx_latest_posts_item_class', calibrefx_row_class());
                $image_class = apply_filters('calibrefx_latest_posts_image_class', col_class(12, 4, 4));
                $content_class = apply_filters('calibrefx_latest_posts_content_class', col_class(12, 8, 8));
                if ($instance['show_thumbnail']) {
                    echo '
						<li>
							<div class="' . $item_class . ' latest-post-item">
								<div class="latest-post-thumb ' . $image_class . '">
									<a href="' . get_permalink() . '" class="thumbnail">' . $img . '</a>
								</div>
								<div class="latest-post-detail ' . $content_class . '">
									<h5 class="latest-post-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h5>
									<p class="latest-post-info">' . do_shortcode('[post_date]') . '</p>
									' . ($instance['show_detail'] ? get_the_content_limit($instance['detail_length']) : '') . '
								</div>
							</div>
						</li>
					';
                } else {
                    echo '
						<li>
							<div class="' . calibrefx_row_class() . ' latest-post-item">
								<div class="latest-post-detail col-lg-12 col-md-12 col-sm-12 col-xs-12">
									<h5 class="latest-post-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h5>
									<p class="latest-post-date">' . date($date_format, get_the_time('U')) . '</p>
									' . ($instance['show_detail'] ? get_the_content_limit($instance['detail_length']) : '') . '
								</div>
							</div>
						</li>
					';
                }
            }
        } else {
            echo '<li>' . __('There is no post available yet', 'calibrefx') . '</li>';
        }
        echo '</ul>';
        echo $after_widget;
        wp_reset_query();
        wp_reset_postdata();
    }
 /**
  * Echo the widget content.
  *
  * @since 0.1.8
  *
  * @global WP_Query $wp_query               Query object.
  * @global array    $_genesis_displayed_ids Array of displayed post IDs.
  * @global $integer $more
  *
  * @param array $args Display arguments including before_title, after_title, before_widget, and after_widget.
  * @param array $instance The settings for the particular instance of the widget
  */
 function widget($args, $instance)
 {
     global $wp_query, $_genesis_displayed_ids;
     //* Merge with defaults
     $instance = wp_parse_args((array) $instance, $this->defaults);
     echo $args['before_widget'];
     //* Set up the author bio
     if (!empty($instance['title'])) {
         echo $args['before_title'] . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $args['after_title'];
     }
     $query_args = array('post_type' => 'post', 'cat' => $instance['posts_cat'], 'showposts' => $instance['posts_num'], 'offset' => $instance['posts_offset'], 'orderby' => $instance['orderby'], 'order' => $instance['order']);
     //* Exclude displayed IDs from this loop?
     if ($instance['exclude_displayed']) {
         $query_args['post__not_in'] = (array) $_genesis_displayed_ids;
     }
     $coldata = badabing_get_colclass($instance['num_cols']);
     $wp_query = new WP_Query($query_args);
     echo '<div class="masonry">';
     if (have_posts()) {
         while (have_posts()) {
             the_post();
             $is_first = $article_num % $coldata['cols'] == 0 ? " first" : "";
             echo "<div class='" . $coldata['class'] . $is_first . " '>";
             $article_num++;
             $_genesis_displayed_ids[] = get_the_ID();
             genesis_markup(array('html5' => '<article %s>', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
             $image = genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-post-widget', 'attr' => genesis_parse_attr('entry-image-widget')));
             /* get the title for this post */
             if (!empty($instance['show_title'])) {
                 $title = get_the_title() ? get_the_title() : __('(no title)', 'genesis');
                 $thetitle = genesis_html5() ? sprintf('<h2 class="entry-title"><a href="%s">%s</a></h2>', get_permalink(), esc_html($title)) : sprintf('<h2><a href="%s">%s</a></h2>', get_permalink(), esc_html($title));
             }
             /* get the entrymeta data */
             if (!empty($instance['show_byline']) && !empty($instance['post_info'])) {
                 $entrymeta = sprintf(genesis_html5() ? '<p class="entry-meta">%s</p>' : '<p class="byline post-info">%s</p>', do_shortcode($instance['post_info']));
             }
             /* get the gravatar */
             if (!empty($instance['show_gravatar'])) {
                 $gravatar = '<span class="' . esc_attr($instance['gravatar_alignment']) . '">';
                 $gravatar .= get_avatar(get_the_author_meta('ID'), $instance['gravatar_size']);
                 $gravatar .= '</span>';
             }
             /* get the content */
             if (!empty($instance['show_content'])) {
                 switch ($instance['show_content']) {
                     case 'excerpt':
                         $content = (int) $instance['content_limit'] > 0 ? substr(get_the_excerpt(), 0, (int) $instance['content_limit']) . '...' : get_the_excerpt();
                         break;
                     case 'content-limit':
                         $content = get_the_content_limit((int) $instance['content_limit'], esc_html($instance['more_text']));
                         break;
                     case 'content':
                     case '':
                     default:
                         $content = apply_filters('the_content', get_the_content($instance['more_text']));
                         break;
                 }
             }
             /* get the permalink button */
             if (!empty($instance['permalink_button']) && $instance['permalink_button']) {
                 switch ($instance['permalink_button_style']) {
                     case 'flbuilder':
                     default:
                         $permalink_button = sprintf('<div class="fl-button-wrap fl-button-width-auto fl-button-right"><a href="%s" target="_self" class="fl-button" role="button"><span class="fl-button-text">%s</span></a></div>', get_permalink(), $instance['more_text']);
                         break;
                     case 'themed':
                         $permalink_button = sprintf('<div class="btn-align-%s"><a href="%s" class="badbtn btn-%s">%s</a></a>', $instance['permalink_button_align'], get_permalink(), $instance['permalink_button_class'], $instance['more_text']);
                         break;
                 }
             }
             switch ($instance['layout_style']) {
                 case 'style1':
                 default:
                     if ($instance['show_image'] && $image) {
                         printf('<div class="bb-feat-style1">%s<a href="%s" title="%s" class="%s img-link"><i class="fa fa-3x fa-arrow-circle-right"></i></a></div>%s %s', $image, get_permalink(), the_title_attribute('echo=0'), esc_attr($instance['image_alignment']), $thetitle, $entrymeta);
                     }
                     echo $gravatar;
                     echo $content;
                     echo $permalink_button;
                     break;
                 case 'style2':
                     if ($instance['show_image'] && $image) {
                         printf('<div class="bb-feat-style2"><a href="%s" title="%s" class="%s">%s</a></div>%s %s', get_permalink(), the_title_attribute('echo=0'), esc_attr($instance['image_alignment']), $image, $thetitle, $entrymeta);
                     }
                     echo $gravatar;
                     echo $content;
                     echo $permalink_button;
                     break;
                 case 'style3':
                     if ($instance['show_image'] && $image) {
                         printf('<div class="bb-feat-style3"><a href="%s" class="bb-feat3-link %s"><div class="bb-feat3-overlay"><span>+</span></div><div class="bb-feat3-image">%s</div><h3>%s</h3></a></div>', get_permalink(), the_title_attribute('echo=0'), $image, $title);
                     }
                     echo $gravatar;
                     echo $content;
                     echo $permalink_button;
                     break;
                 case 'style4':
                     if ($instance['show_image'] && $image) {
                         printf('<div class="bb-feat-style4"><a href="%s" class="bb-feat4-link %s"><div class="bb-feat4-overlay"><span>+</span></div><div class="bb-feat4-image">%s</div><h3>%s</h3></a>', get_permalink(), the_title_attribute('echo=0'), $image, $title);
                     }
                     echo !empty($instance['show_byline']) && !empty($instance['post_info']) ? '<div class="bb-feat4-meta">' . $entrymeta . '</div>' : '';
                     printf('</div>');
                     echo $gravatar;
                     echo $content;
                     echo $permalink_button;
                     break;
                 case 'style5':
                     printf('<a href="%s" class="bb-feat-style5"><div class="image">%s<h4 class="posted-date">%s</div>' . '<div class="the-excerpt">' . '<h3>%s</h3>' . '%s<br>' . '<span>%s</span>' . '</div></a>', get_permalink(), $image, $entrymeta, $title, $content, $instance['more_text']);
                     break;
             }
             genesis_markup(array('html5' => '</article>', 'xhtml' => '</div>'));
             echo "</div>";
         }
         while ($article_num % $coldata['cols'] != 0) {
             echo "<div class='" . $coldata['class'] . "'></div>";
             $article_num++;
         }
     }
     echo '</div>';
     // end .masonry class
     //* Restore original query
     wp_reset_query();
     //* The EXTRA Posts (list)
     if (!empty($instance['extra_num'])) {
         if (!empty($instance['extra_title'])) {
             echo $args['before_title'] . esc_html($instance['extra_title']) . $args['after_title'];
         }
         $offset = intval($instance['posts_num']) + intval($instance['posts_offset']);
         $query_args = array('cat' => $instance['posts_cat'], 'showposts' => $instance['extra_num'], 'offset' => $offset);
         $wp_query = new WP_Query($query_args);
         $listitems = '';
         if (have_posts()) {
             while (have_posts()) {
                 the_post();
                 $_genesis_displayed_ids[] = get_the_ID();
                 $listitems .= sprintf('<li><a href="%s">%s</a></li>', get_permalink(), get_the_title());
             }
             if (mb_strlen($listitems) > 0) {
                 printf('<ul>%s</ul>', $listitems);
             }
         }
         //* Restore original query
         wp_reset_query();
     }
     if (!empty($instance['more_from_category']) && !empty($instance['posts_cat'])) {
         printf('<p class="more-from-category"><a href="%1$s" title="%2$s">%3$s</a></p>', esc_url(get_category_link($instance['posts_cat'])), esc_attr(get_cat_name($instance['posts_cat'])), esc_html($instance['more_from_category_text']));
     }
     echo $args['after_widget'];
 }
Ejemplo n.º 3
0
/**
 * Echo the limited content.
 *
 * @since 0.1.0
 *
 * @uses get_the_content_limit() Return content stripped down and limited content.
 *
 * @param integer $max_characters The maximum number of characters to return.
 * @param string  $more_link_text Optional. Text of the more link. Default is "(more...)".
 * @param bool    $stripteaser    Optional. Strip teaser content before the more text. Default is false.
 */
function the_content_limit($max_characters, $more_link_text = '(more...)', $stripteaser = false)
{
    $content = get_the_content_limit($max_characters, $more_link_text, $stripteaser);
    echo apply_filters('the_content_limit', $content);
}
Ejemplo n.º 4
0
/**
 * ==============================================================
 * Post
 * ==============================================================
 */
function calibrefx_post_item($atts, $content = null)
{
    extract(shortcode_atts(array('post_type' => 'post', 'post_id' => '', 'limit' => 0, 'limit_text' => 'Read More', 'show_title' => 1, 'is_title_link' => 0, 'show_featured_image' => 0, 'before' => '', 'after' => '', 'class' => '', 'id' => '', 'style' => ''), $atts));
    if (empty($post_id)) {
        return;
    }
    $args = array();
    if ($post_type != 'post') {
        $args['post_type'] = $post_type;
        if (!empty($post_id)) {
            $args['page_id'] = $post_id;
        }
    } else {
        if (!empty($post_id)) {
            $args['p'] = $post_id;
        }
    }
    $args['posts_per_page'] = 1;
    $query = new WP_Query($args);
    $html = '';
    if ($query->have_posts()) {
        $post_class = '';
        foreach (get_post_class() as $class_item => $val) {
            $post_class .= ' ' . $val;
        }
        $html .= '<div class="post-item' . $post_class . ' ' . $class . '">';
        while ($query->have_posts()) {
            $query->the_post();
            if ($show_title) {
                if ($is_title_link) {
                    $html .= '<h2 class="post-item-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>';
                } else {
                    $html .= '<h2 class="post-item-title">' . get_the_title() . '</h2>';
                }
            }
            if ($show_featured_image) {
                $post_img = calibrefx_get_image(array('format' => 'html', 'size' => ''));
                $html .= $post_img;
            }
            if ($limit) {
                $html .= get_the_content_limit($limit, $limit_text);
            } else {
                $html .= wpautop(get_the_content(), true);
            }
        }
        $html .= '</div><!-- end .post-item -->';
    }
    wp_reset_query();
    wp_reset_postdata();
    return do_shortcode($html);
}
Ejemplo n.º 5
0
function zp_blog($columns, $items)
{
    global $post;
    $output = '';
    $size = '3col_blog';
    $recent = new WP_Query(array('post_type' => 'post', 'posts_per_page' => $items));
    $output .= '<div class="blog_items">';
    //check the no of columns
    $no_of_col = $columns;
    if ($columns == 2) {
        $columns = 'col-md-6 col-sm-6 col-xs-12';
        $size = '2col_blog';
    } elseif ($columns == 3) {
        $columns = 'col-sm-6 col-md-4 col-xs-12';
        $size = '3col_blog';
    } elseif ($columns == 4) {
        $columns = 'col-md-3 col-sm-6 col-xs-12';
        $size = '4col_blog';
    }
    $flag = 0;
    while ($recent->have_posts()) {
        $recent->the_post();
        $flag++;
        if ($flag == 0 || $flag % $no_of_col == 1) {
            $output .= '<div class="row">';
        }
        $image_url = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
        $image = get_the_post_thumbnail($post->ID, $size, array('class' => 'img-responsive'));
        // get the number of comments
        $num_comments = get_comments_number();
        if (comments_open()) {
            if ($num_comments == 0) {
                $comments = __('No Comments', 'start');
            } elseif ($num_comments > 1) {
                $comments = $num_comments . __(' Comments', 'start');
            } else {
                $comments = __('1 Comment', 'start');
            }
            $write_comments = '<a class="blog_comment" href="' . get_comments_link() . '">' . $comments . '</a>';
        } else {
            $write_comments = __('Comments are OFF', 'start');
        }
        $output .= '<div class="' . $columns . '"><div class="thumbnail">';
        $output .= '<a href="' . get_permalink() . '">' . $image . '</a>';
        $output .= '<div class="caption"><h4><a href="' . get_permalink() . '">' . get_the_title() . '</a></h4><span class="blog_meta">' . get_the_date('F j, Y') . $write_comments . '</span>' . get_the_content_limit(100, '') . '<a class="readmore btn btn-primary btn-lg" href="' . get_permalink() . '">' . __('Read More', 'start') . '</a></div>';
        $output .= '</div></div>';
        if ($flag % $no_of_col == 0) {
            $output .= '</div>';
        }
    }
    wp_reset_query();
    $output .= '</div>';
    return $output;
}
Ejemplo n.º 6
0
 function widget($args, $instance)
 {
     $args = $this->override_args($args, $instance);
     extract($args);
     $term_args = array();
     $terms = array();
     $term = $this->get_current_term();
     if ('page' != $instance['post_type']) {
         switch ($instance['source_type']) {
             case "parent":
                 $term = $this->get_top_term($term);
                 break;
             case "current":
                 break;
             default:
                 $term = $this->get_instance_term($instance['posts_term']);
         }
         if ($term) {
             $term_args['tax_query'] = array(array('taxonomy' => $term->taxonomy, 'field' => 'id', 'terms' => count($terms) > 0 ? $terms : $term->term_id));
             if ($instance['exclude_terms']) {
                 $exclude_terms = explode(',', str_replace(' ', '', $instance['exclude_terms']));
                 $term_args[$term->taxonomy . '__not_in'] = $exclude_terms;
             }
         }
     }
     if ($instance['post_id']) {
         $IDs = explode(',', str_replace(' ', '', $instance['post_id']));
         if ('include' == $instance['include_exclude']) {
             $term_args['post__in'] = $IDs;
         } else {
             $term_args['post__not_in'] = $IDs;
         }
     }
     if ($instance['posts_offset']) {
         $myOffset = $instance['posts_offset'];
         $term_args['offset'] = $myOffset;
     }
     $query_args = array_merge($term_args, array('post_type' => $instance['post_type'], 'posts_per_page' => $instance['posts_num'], 'orderby' => $instance['orderby']));
     $wrap = $instance['show_excerpt'];
     echo $before_widget;
     $posts = array();
     $posts = new WP_Query($query_args);
     while ($posts->have_posts()) {
         $posts->the_post();
         $permalink = get_permalink();
         $title = get_the_title();
         $post_title = $instance['show_title'] ? sprintf('<a rel="bookmark" href="%1$s">%2$s</a>', $permalink, esc_html($title)) : '';
         if ($instance['show_image'] && ($image = genesis_get_image(array('format' => 'html', 'size' => $instance['image_size'], 'context' => 'featured-post-widget', 'attr' => genesis_parse_attr('entry-image-widget'))))) {
             $post_image = sprintf('<a href="%s" title="%s" class="%s">%s</a>', $permalink, the_title_attribute('echo=0'), esc_attr($instance['image_align']), $image);
         } else {
             $post_image = '';
         }
         if ($instance['show_excerpt']) {
             if ($instance['show_content']) {
                 if ($instance['show_limit']) {
                     $post_excerpt = get_the_content_limit((int) $instance['show_limit']);
                 } else {
                     $post_excerpt = get_the_content($instance['show_more'] ? null : '');
                 }
             } else {
                 $post_excerpt = get_the_excerpt();
             }
         } else {
             $post_excerpt = '';
         }
         if ($wrap) {
             genesis_markup(array('html5' => '<article %s>', 'xhtml' => sprintf('<div class="%s">', implode(' ', get_post_class())), 'context' => 'entry'));
         }
         if (!empty($post_title) || !empty($post_image)) {
             printf(genesis_html5() ? '<header class="entry-header"><h2 class="entry-title">%1$s%2$s</h2></header>' : '<h2>%1$s%2$s</h2>', $post_image, $post_title);
         }
         if (!empty($post_excerpt)) {
             printf(genesis_html5() ? '<div class="entry-content">%1$s</div>' : '%1$s', $post_excerpt);
         }
         if ($wrap) {
             genesis_markup(array('html5' => '</article>', 'xhtml' => '</div>'));
         }
     }
     echo $after_widget;
     wp_reset_query();
 }
/**
 * Displays All Post 
 * Used in shortcode
 * @blog_cloumns integer - number of columns
 * @blog_items integer  - number of items
 * @blog_cat string - post category to be displayed (uses the category slud)
 
 *
*/
function zp_post_shortcode($blog_cloumns, $blog_items, $blog_cat)
{
    global $post;
    /** get appropriate columns, image height and image width*/
    $_values = zp_portfolio_items_values($blog_cloumns);
    $args = array('post_type' => 'post', 'posts_per_page' => $blog_items, 'category_name' => $blog_cat);
    query_posts($args);
    $output = '';
    $html = '';
    $output .= ' <div  class="blog_feature_shortcode">';
    $output .= '<ul class="blog_slides">';
    if (have_posts()) {
        while (have_posts()) {
            the_post();
            $description = get_the_content_limit(150, '');
            $Old = array('<p>', '</p>');
            $description = str_replace($Old, '', $description);
            $thumbnail = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
            $html .= '<li class="element' . $_values['class'] . '">';
            $html .= '<div class="home_blog_feature">';
            $html .= '<div class="blog_feature_image">';
            $html .= '<a href="' . get_permalink() . '">';
            $html .= get_the_post_thumbnail($post->ID, $_values['size']);
            $html .= '<div class="blog_feature_content"><h3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>';
            if (genesis_get_option('zp_home_blog_itemdesc', ZP_SETTINGS_FIELD)) {
                $html .= '<p><span class="home-blog-post-meta">' . get_the_date('F j, Y') . '</span>';
                $html .= '<span class="post_box_comments">';
                $html .= '<a href="' . get_comments_link($post->ID) . '">' . zp_custom_comment_number() . '</a>';
                $html .= '</span></p>';
                $html .= '<p>' . $description . '[...]</p>';
            }
            $html .= '</div></div></li>';
        }
    }
    wp_reset_query();
    $output .= $html;
    $output .= '</ul>';
    $output .= '</div>';
    return $output;
}