コード例 #1
0
ファイル: popularposts.php プロジェクト: closings/closings
 function widget($args, $instance)
 {
     global $post;
     $excerpt = NULL;
     $comment_input = NULL;
     extract($args, EXTR_SKIP);
     echo $before_widget;
     $title = empty($instance['title']) ? __('Popular Posts', 'lan-thinkupthemes') : apply_filters('widget_title', $instance['title']);
     if (!empty($title)) {
         echo $before_title . $title . $after_title;
     }
     $posts = new WP_Query('orderby=comment_count&posts_per_page=' . $instance['postcount'] . '');
     while ($posts->have_posts()) {
         $posts->the_post();
         /* Insert excerpt if needed. */
         if ($instance['excerpt'] == 'on') {
             if (is_numeric($instance['excerptlength'])) {
                 $excerpt_input = $instance['excerptlength'];
             } else {
                 $excerpt_input = '45';
             }
             $excerpt = '<a class="excerpt" href="' . get_permalink() . '">' . substr(get_the_excerpt(), 0, $excerpt_input) . '...</a>';
         }
         // Insert comments if needed.
         if ($instance['comments'] == 'on') {
             $comment_input = get_comments_popup_link(__('No Comments', 'lan-thinkupthemes'), __('1 Comment', 'lan-thinkupthemes'), __('% Comments', 'lan-thinkupthemes'), 'comment');
         }
         // HTML output
         echo '<div class="popular-posts">';
         if (has_post_thumbnail()) {
             echo '<div class="image">', '<a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_post_thumbnail($post->ID, array(65, 65)) . '<div class="image-overlay"></div></a>', '</div>', '<div class="main">', '<a class="title" href="' . get_permalink() . '">' . get_the_title() . '</a>', $excerpt, $comment_input, '</div>';
         } else {
             echo '<div class="main">', '<a class="title" href="' . get_permalink() . '">' . get_the_title() . '</a>', $excerpt, $comment_input, '</div>';
         }
         echo '</div>';
     }
     wp_reset_query();
     echo $after_widget;
 }
コード例 #2
0
/**
 * Show posted on
 *
 * Prints HTML with meta information for the current post-date/time and author.
 *
 * @since 5.0.0
 *
 * @return void
 */
function posted_on()
{
    $time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time>';
    if (get_the_time('U') !== get_the_modified_time('U')) {
        $time_string .= '<time class="updated" datetime="%3$s">%4$s</time>';
    }
    $time_string = sprintf($time_string, esc_attr(get_the_date('c')), esc_html(get_the_date('F jS, Y')), esc_attr(get_the_modified_date('c')), esc_html(get_the_modified_date('F jS, Y')));
    $posted_on = '<span class="posted-on">' . $time_string . '</span>';
    if (get_the_author_meta('ID') !== 2) {
        $byline = sprintf(_x(' by %s', 'post author', 'chriswiegman'), '<span class="byline"> <span class="author vcard"><a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . esc_html(get_the_author()) . '</a></span> </span>');
    } else {
        $byline = '';
    }
    if (!post_password_required() && (comments_open() || 0 !== get_comments_number())) {
        $comments = sprintf('<span class="comments-link">%s</span>', get_comments_popup_link());
    } else {
        $comments = '';
    }
    $edit_link = get_edit_post_link();
    if (null !== $edit_link) {
        $edit = sprintf(' | <span class="edit-link"><a href="%s">%s</a></span>', $edit_link, esc_attr__('Edit', 'chriswiegman'));
    } else {
        $edit = '';
    }
    echo $posted_on . $byline . $comments . $edit;
    // WPCS: XSS OK.
}
コード例 #3
0
ファイル: shortcodes.php プロジェクト: scarlettkuro/kanon
function fruitful_recent_posts_slider($atts)
{
    //Add FlexSlider
    wp_enqueue_style('flex-slider', get_template_directory_uri() . '/js/flex_slider/slider.css');
    wp_enqueue_script('flex-fitvid-j', get_template_directory_uri() . '/js/flex_slider/jquery.flexslider-min.js', array('jquery'), '20130930', false);
    wp_enqueue_script('flex-slider', FRUITFUL_SHORTCODE_URI . 'includes/shortcodes/js/slider_init.js', array('jquery'));
    extract(shortcode_atts(array('posts' => 4, 'cat' => '', 'excerpt' => ''), $atts));
    if (!empty($cat)) {
        $cats = explode(", ", $cat);
        $args = array('orderby' => 'modified', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'posts_per_page' => $posts, 'tax_query' => array(array('taxonomy' => 'category', 'field' => 'slug', 'terms' => $cats)));
    } else {
        $args = array('orderby' => 'modified', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'posts_per_page' => $posts);
    }
    $my_query = new WP_Query($args);
    if ($my_query->have_posts()) {
        $out1 = "";
        $out1 .= '<div class="flexslider">
		<ul class="slides">';
        while ($my_query->have_posts()) {
            $my_query->the_post();
            $day = get_the_date('d');
            $month_abr = get_the_date('M');
            $the_ID = get_the_ID();
            $post_class = get_post_class();
            $the_permalink = get_the_permalink();
            $title = esc_attr(sprintf(__('Permalink to %s', 'fruitful'), the_title_attribute('echo=0')));
            $the_title = get_the_title();
            $the_post_thumbnail = get_the_post_thumbnail();
            if ($excerpt == 0) {
                $the_excerpt = get_the_content();
            } else {
                $the_excerpt = get_the_excerpt();
            }
            $the_category = get_the_category_list(', ', 'fruitful');
            $comments = get_comments_popup_link(__('Leave a comment', 'fruitful'), __('1 Comment', 'fruitful'), __('% Comments', 'fruitful'));
            $out1 .= '<li>';
            $out1 .= '<article id="post-' . $the_ID . '" class="blog_post blog ' . implode(' ', $post_class) . '">';
            $out1 .= '<a href="' . $the_permalink . '" rel="bookmark">
				<div class="date_of_post updated">
					<span class="day_post">' . $day . '</span>
					<span class="month_post">' . $month_abr . '</span>
				</div>
			</a>';
            $out1 .= '<div class="post-content">	
		<header class="post-header">
			<h2 class="post-title entry-title">
				<a href="' . $the_permalink . '" title="' . $title . '" rel="bookmark">' . $the_title . '</a>
			</h2>
		</header><!-- .entry-header -->';
            $out1 .= '<div class="entry-content">';
            if (has_post_thumbnail() && !post_password_required()) {
                $out1 .= '<div class="entry-thumbnail">' . $the_post_thumbnail . '</div>';
            }
            $out1 .= $the_excerpt . '</div><!-- .entry-content -->';
            $out1 .= '<footer class="entry-meta">
			<span class="author-link author"><a href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '">' . get_the_author() . '</a></span>
			<span class="cat-links">
			Posted in ' . $the_category . '
			</span>
			<span class="comments-link">
			' . $comments . '
		</span> ';
            $out1 .= '</footer>
		</div>
	</article></li>';
        }
        $out1 .= '</ul>';
        $out1 .= '</div>';
        $out1 .= '<div class="clearfix"></div>';
    }
    return $out1;
    wp_reset_query();
}
コード例 #4
0
function uniq_get_comments_meta()
{
    if (!is_single() && !post_password_required() && (comments_open() || get_comments_number())) {
        $comments_meta = '| <span class="comments-link"><i class="fa fa-comments"></i>';
        $comments_meta .= get_comments_popup_link(__('Leave a comment', 'uniq'), __('1 Comment', 'uniq'), __('% Comments', 'uniq'));
        $comments_meta .= '</span>';
        return $comments_meta;
    }
}
コード例 #5
0
ファイル: blog.php プロジェクト: tharindulucky/premium-demo
    /**
     * Render the widget in frontend
     *
     * @param array $args
     * @param array $instance
     * @return string
     */
    function get_widget($args, $instance)
    {
        if (is_admin()) {
            return "<center><i class='icon-list-alt  icon-4x'></i></center>";
        }
        $output = '';
        if (empty($instance['categories'])) {
            $instance['categories'] = "";
        }
        if (isset($instance['link']) && isset($instance['blog_type']) && $instance['blog_type'] == 'taxonomy') {
            //$instance['link'] = explode(',', $instance['link'], 2);
            $instance['taxonomy'] = $instance['link'][0];
            if (!empty($instance['link'][1])) {
                $instance['categories'] = $instance['link'][1];
            } else {
                if (!empty($instance['taxonomy'])) {
                    $taxonomy_terms_obj = get_terms($instance['taxonomy']);
                    foreach ($taxonomy_terms_obj as $taxonomy_term) {
                        $instance['categories'] .= $taxonomy_term->term_id . ',';
                    }
                }
            }
        }
        $instance = wp_parse_args($instance, array('blog_style' => '', 'columns' => 3, 'blog_type' => 'posts', 'items' => '16', 'paginate' => 'yes', 'categories' => '', 'preview_mode' => 'auto', 'image_size' => '6_column', 'post_type' => 'post', 'taxonomy' => 'category', 'contents' => 'excerpt', 'content_length' => 'content', 'offset' => '0', 'excerpt_length' => '55', 'post_meta' => '1', 'widget_title' => ''));
        $this->excerpt_length = $instance['excerpt_length'];
        add_filter('excerpt_length', array($this, 'custom_excerpt_length'), 999);
        $this->query_entries($instance);
        $instance['blog_content'] = $instance['content_length'];
        $instance['remove_pagination'] = $instance['paginate'] === "yes" ? false : true;
        //print_r($instance);
        $more = 0;
        //ob_start(); //start buffering the output instead of echoing it
        //include_once ReduxPageBuilder::$_dir . '/inc/loop-index.php';
        global $options, $post_loop_count, $wp_query;
        //default for temprory
        $options['blog_style'] = 'small-featured';
        $options['single_post_style'] = 'small-featured';
        if (empty($post_loop_count)) {
            $post_loop_count = 1;
        }
        $blog_style = !empty($instance['blog_style']) ? $instance['blog_style'] : $options['blog_style'];
        //if (is_single())
        //    $blog_style = $options['single_post_style'];
        $blog_content = !empty($instance['blog_content']) ? $instance['blog_content'] : "content";
        //        $output = "
        //            <style type='text/css'>
        //                .Redux_Widget_video{
        //                    display: none;
        //                }
        //            </style>
        //         ";
        ?>

        <?php 
        if (!empty($instance['widget_title'])) {
            $output .= "<h3 class='widget-title blog-widget-title'>{$instance['widget_title']}</h3>";
        }
        // check if we got posts to display:
        if (have_posts()) {
            while (have_posts()) {
                the_post();
                /*
                 * get the current post id, the current post class and current post format
                 */
                $column_width = "";
                switch ($blog_style) {
                    case 'list-large':
                    case 'list-medium':
                    case 'list-small':
                        $column_width = "col-md-12";
                        break;
                    case 'grid-medium':
                        $column_width = "col-md-4";
                        break;
                    case 'grid-small':
                        $column_width = "col-md-3 col-xs-4";
                        break;
                    case 'grid-mini':
                        $column_width = "col-md-2 col-xs-3";
                        break;
                }
                $the_id = get_the_ID();
                $parity = $post_loop_count % 2 ? 'odd' : 'even';
                $last = count($wp_query->posts) == $post_loop_count ? " post-entry-last " : "";
                $post_class = "post-entry-" . $the_id . " post-loop-" . $post_loop_count . " post-parity-" . $parity . $last . " " . $column_width . " ";
                $post_format = get_post_format() ? get_post_format() : 'standard';
                /*
                 * retrieve slider, title and content for this post,...
                 */
                $size = '9_culomn';
                if (!empty($instance['preview_mode']) && !empty($instance['image_size']) && $instance['preview_mode'] == 'custom') {
                    $size = $instance['image_size'];
                }
                $current_post['slider'] = get_the_post_thumbnail($the_id, $size);
                $current_post['title'] = get_the_title();
                $current_post['content'] = $blog_content == "content" ? get_the_content(__('Read more', 'redux-page-builder') . '<span class="more-link-arrow">  &rarr;</span>') : get_the_excerpt();
                $current_post['content'] = $blog_content == "excerpt_read_more" ? $current_post['content'] . '<div class="read-more-link"><a href="' . get_permalink() . '" class="more-link">' . __('Read more', 'redux-page-builder') . '<span class="more-link-arrow">  &rarr;</span></a></div>' : $current_post['content'];
                $current_post['before_content'] = "";
                /*
                 * ...now apply a filter, based on the post type... (filter function is located in includes/helper-post-format.php)
                 */
                $current_post = apply_filters('post-format-' . $post_format, $current_post);
                $with_slider = empty($current_post['slider']) ? "" : "with-slider";
                /*
                 * ... last apply the default wordpress filters to the content
                 */
                $current_post['content'] = str_replace(']]>', ']]&gt;', apply_filters('the_content', $current_post['content']));
                /*
                 * Now extract the variables so that $current_post['slider'] becomes $slider, $current_post['title'] becomes $title, etc
                 */
                extract($current_post);
                /*
                 * render the html:
                 */
                $output .= "<article class=' " . implode(" ", get_post_class('post-entry post-entry-type-' . $post_format . " " . $post_class . " " . $with_slider)) . "' " . schema_markup(array('context' => 'entry', 'echo' => false)) . "><div class='inner-entry post-loop'>";
                //default link for preview images
                $link = get_permalink();
                //echo preview image
                //if (strpos($blog_style, 'big') !== false) {
                if ($slider) {
                    $slider = '<a href="' . $link . '">' . $slider . '</a>';
                }
                if ($slider) {
                    $output .= '<div class="big-preview ' . $blog_style . '">' . $slider . ' </div>';
                }
                //}
                if (!empty($before_content)) {
                    $output .= '<div class="big-preview ' . $blog_style . '">' . $before_content . '</div>';
                }
                $output .= "<div class='entry-content-wrapper clearfix {$post_format}-content'><div class='arrow'></div>";
                $output .= '<header class="entry-content-header">';
                //                if($blog_style == 'grid-mini')
                //                    $output .= modifier_truncate($title,100);
                //                elseif($blog_style == 'grid-small')
                //                    $output .= modifier_truncate($title,20);
                //                else
                $output .= $title;
                if ($instance['post_meta']) {
                    $output .= "<span class='post-meta-infos'>";
                    $markup = schema_markup(array('context' => 'entry_time', 'echo' => false));
                    $output .= "<time class='date-container minor-meta updated' {$markup}><i class='icon-time'></i> " . get_the_time(get_option('date_format')) . "</time>";
                    //$output .= "<span class='text-sep text-sep-date'>/</span>";
                    if (get_comments_number() != "0" || comments_open()) {
                        $output .= "<span class='comment-container minor-meta'><i class='icon-comment'></i> ";
                        $output .= get_comments_popup_link("0 " . __('Comments', 'redux-page-builder'), "1 " . __('Comment', 'redux-page-builder'), "% " . __('Comments', 'redux-page-builder'), 'comments-link', "" . __('Comments Disabled', 'redux-page-builder'));
                        $output .= "</span>";
                        //$output .= "<span class='text-sep text-sep-comment'>/</span>";
                    }
                    $taxonomies = get_object_taxonomies(get_post_type($the_id));
                    $cats = '';
                    $excluded_taxonomies = apply_filters('exclude_taxonomies', array('post_tag', 'post_format'), get_post_type($the_id), $the_id);
                    if (!empty($taxonomies)) {
                        foreach ($taxonomies as $taxonomy) {
                            if (!in_array($taxonomy, $excluded_taxonomies)) {
                                $cats .= get_the_term_list($the_id, $taxonomy, '', ', ', '') . ' ';
                            }
                        }
                    }
                    if (!empty($cats)) {
                        $output .= '<span class="blog-categories minor-meta"><i class="icon-tags"></i> ' . __('in', 'redux-page-builder') . " ";
                        $output .= $cats;
                        $output .= '</span>';
                    }
                    $output .= '<span class="blog-author minor-meta"><i class="icon-user"></i> ' . __('by', 'redux-page-builder') . " ";
                    $output .= '<span class="entry-author-link" ' . schema_markup(array('context' => 'author_name', 'echo' => false)) . '>';
                    $output .= '<span class="vcard author"><span class="fn">';
                    $output .= get_the_author_posts_link();
                    $output .= '</span></span>';
                    $output .= '</span>';
                    $output .= '</span>';
                    $output .= '</span>';
                }
                $output .= '</header>';
                // echo the post content
                $output .= '<div class="entry-content" ' . schema_markup(array('context' => 'entry_content', 'echo' => false)) . '>';
                $output .= $content;
                $output .= '</div>';
                $output .= '<footer class="entry-footer">';
                wp_link_pages(array('before' => '<div class="pagination_split_post">', 'after' => '</div>', 'pagelink' => '<span>%</span>'));
                if (has_tag() && is_single() && !post_password_required()) {
                    $output .= '<span class="blog-tags minor-meta">';
                    the_tags('<strong>' . __('Tags:', 'redux-page-builder') . '</strong><span> ');
                    $output .= '</span></span>';
                }
                $output .= '</footer>';
                $output .= "<div class='post_delimiter'></div>";
                $output .= "</div><div class='clearfix'></div>";
                $output .= "</div></article>";
                $post_loop_count++;
            }
        } else {
            ?>

            <article class="entry">
                <header class="entry-content-header">
                    <h1 class='post-title entry-title'><?php 
            _e('Nothing Found', 'redux-page-builder');
            ?>
</h1>
                </header>

                <p class="entry-content" <?php 
            schema_markup(array('context' => 'entry_content'));
            ?>
><?php 
            _e('Sorry, no posts matched your criteria', 'redux-page-builder');
            ?>
</p>

                <footer class="entry-footer"></footer>
            </article>

        <?php 
        }
        $output .= "<div class='clearfix'></div>";
        if (isset($instance['remove_pagination']) && $instance['remove_pagination'] === false) {
            $output .= "<div class='{$blog_style}'>" . pagination($wp_query, false) . "</div>";
        }
        //$output = ob_get_clean();
        wp_reset_query();
        if ($output) {
            $markup = schema_markup(array('context' => 'blog', 'echo' => false));
            $output = "<div class='{$blog_style} template-blog' {$markup}>{$output}</div>";
        }
        return $output;
    }