Exemplo n.º 1
0
    /**
     * Display widget
     *
     * @param array $args     Sidebar configuration
     * @param array $instance Widget settings
     *
     * @return void
     */
    function widget($args, $instance)
    {
        $instance = wp_parse_args($instance, $this->defaults);
        extract($instance);
        $query_args = array('posts_per_page' => $limit, 'post_status' => 'publish', 'post_type' => 'post', 'ignore_sticky_posts' => true);
        if (!empty($cat) && is_array($cat)) {
            $query_args['category__in'] = $cat;
        }
        $query = new WP_Query($query_args);
        if (!$query->have_posts()) {
            return;
        }
        extract($args);
        echo $before_widget;
        if ($title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base)) {
            echo $before_title . $title . $after_title;
        }
        while ($query->have_posts()) {
            $query->the_post();
            $class = $thumb ? '' : ' fitwp-list';
            ?>
			<article class="fitwp-recent-post <?php 
            echo $class;
            ?>
">
				<?php 
            if ($thumb) {
                $src = constructent_post_thumbnail_src('constructent-widget-thumb');
                if (!$src) {
                    $src = $thumb_default;
                }
                if ($src) {
                    printf('<a class="fitwp-thumb" href="%s" title="%s"><img src="%s" alt="%s"></a>', get_permalink(), the_title_attribute('echo=0'), $src, the_title_attribute('echo=0'));
                }
            }
            ?>
				<div class="fitwp-text">
					<a class="fitwp-title" href="<?php 
            the_permalink();
            ?>
" title="<?php 
            printf(esc_attr__('Permalink to %s', 'constructent'), the_title_attribute('echo=0'));
            ?>
" rel="bookmark"><?php 
            the_title();
            ?>
</a>
					<?php 
            if ($date) {
                echo '<time class="fitwp-date" datetime="' . esc_attr(get_the_time('c')) . '">' . esc_html(get_the_time($date_format)) . '</time>';
            }
            if ($comments) {
                echo '<span class="fitwp-comments">' . sprintf(esc_html__('%s Comments', 'constructent'), get_comments_number()) . '</span>';
            }
            if ($excerpt) {
                $more = $readmore ? $readmore_text : '';
                echo '<div class="fitwp-excerpt">' . constructent_content_limit($length, $more, false) . '</div>';
            }
            ?>
				</div>
			</article>
		<?php 
        }
        wp_reset_postdata();
        echo $after_widget;
    }
Exemplo n.º 2
0
    /**
     * Show team shortcode
     *
     * @param array $atts
     * @param string $content
     *
     * @return string
     */
    function team($atts, $content)
    {
        $atts = shortcode_atts(array('number' => 10, 'columns' => 4, 'orderby' => 'date', 'order' => 'DESC'), $atts, 'team');
        $args = array('post_type' => 'team_member', 'posts_per_page' => absint($atts['number']), 'orderby' => $atts['orderby'], 'order' => $atts['order']);
        $members = new WP_Query($args);
        if (!$members->have_posts()) {
            return '';
        }
        $socials = array('facebook', 'twitter', 'google', 'linkedin', 'tumblr');
        $list = array();
        while ($members->have_posts()) {
            $members->the_post();
            $links = array();
            foreach ($socials as $social) {
                $url = constructent_meta($social);
                if ($url) {
                    $links[] = sprintf('<li><a href="%s" rel="nofollow" target="_blank"><i class="fa fa-%s"></i></a></li>', esc_url($url), $social == 'google' ? 'google-plus' : $social);
                }
            }
            $list[] = sprintf('<div class="team-member clearfix">
					%s
					<div class="member-bio">
						%s
					</div>
					<div class="member-info">
						<h5 class="name">%s</h5>
						<span class="position">%s</span>
					</div>
					%s
				</div>', constructent_get_image('size=constructent-member-thumbnail&echo=0'), constructent_content_limit(12, false, false), get_the_title(), constructent_meta('job'), $links ? '<ul class="social-icons">' . implode("\n", $links) . '</ul>' : '');
        }
        wp_reset_postdata();
        return sprintf('<div class="fitsc-team"><div class="team-members" data-items="%d">%s</div></div>', absint($atts['columns']), implode("\n", $list));
    }
Exemplo n.º 3
0
/**
 * Display entry content or summary
 *
 * @return void
 */
function constructent_entry_content()
{
    if (is_singular()) {
        echo '<div class="entry-content">';
        the_content();
        constructent_entry_meta();
        if (is_single()) {
            the_post_navigation($args = array('prev_text' => esc_html__('Previous Post', 'constructent'), 'next_text' => esc_html__('Next Post', 'constructent')));
        }
        echo '</div>';
        return;
    }
    // Display type
    $display = constructent_option('blog_display');
    // Allow to config via global variable
    if (!$display) {
        $display = 'content';
    }
    echo '<div class="entry-summary">';
    // Excerpt
    if ('excerpt' == $display) {
        the_excerpt();
        return;
    }
    // Check is post format audio
    if (!has_post_format('audio')) {
        $more_text = constructent_more_text();
    } else {
        $more_text = '';
    }
    // Post content before more tag
    if ('more' == $display) {
        if (is_page_template('tpl/blog.php')) {
            global $more;
            $more = false;
        }
        the_content($more_text);
        wp_link_pages(array('before' => '<p class="pages">' . esc_html__('Pages:', 'constructent'), 'after' => '</p>', 'link_before' => '<span>', 'link_after' => '</span>'));
    } else {
        $content = constructent_content_limit(constructent_content_length(), $more_text, false);
        echo constructent_post_formats_content($content);
    }
    echo '</div>';
    // .entry-summary
}