コード例 #1
0
    function widget($args, $instance)
    {
        $cache = wp_cache_get('smartlib-recent-posts', 'widget');
        /*
        		if ( ! is_array( $cache ) )
        			$cache = array();
        
        		if ( ! isset( $args['widget_id'] ) )
        			$args['widget_id'] = $this->id;
        
        		if ( isset( $cache[$args['widget_id']] ) ) {
        			echo $cache[$args['widget_id']];
        			return;
        		}
        
        		ob_start();
        */
        extract($args);
        $title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Posts', 'maxflat') : $instance['title'], $instance, $this->id_base);
        if (empty($instance['number']) || !($number = absint($instance['number']))) {
            $number = 10;
        }
        $show_date = isset($instance['show_date']) ? $instance['show_date'] : false;
        $show_post_thumbnail = isset($instance['show_post_thumbnail']) ? $instance['show_post_thumbnail'] : false;
        $show_post_author = isset($instance['show_post_author']) ? $instance['show_post_author'] : false;
        $r = new WP_Query(apply_filters('widget_posts_args', array('posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'ignore_sticky_posts' => true)));
        if ($r->have_posts()) {
            ?>

		<?php 
            echo $before_widget;
            ?>

		<?php 
            if ($title) {
                echo $before_title . $title . $after_title;
            }
            ?>

		<ul class="no-bullet">
			<?php 
            while ($r->have_posts()) {
                $r->the_post();
                ?>

			<li>

					<?php 
                if ('' != get_the_post_thumbnail() && $show_post_thumbnail) {
                    ?>


                        <a href="<?php 
                    the_permalink();
                    ?>
" class="smartlib-widget-image-outer"><?php 
                    the_post_thumbnail('small-image');
                    ?>
</a>

						<?php 
                }
                ?>

				<header class="smartlib-widget-header">
					<h5 class="widget-post-title"><a href="<?php 
                the_permalink();
                ?>
"><?php 
                if (get_the_title()) {
                    the_title();
                } else {
                    the_ID();
                }
                ?>
</a></h5>
				</header>
				<?php 
                if ($show_date) {
                    ?>

				<?php 
                    maxflat_display_meta_post('date');
                    ?>

				<?php 
                }
                ?>

					<?php 
                if ($show_post_author) {
                    ?>

				  <?php 
                    maxflat_author_line();
                    ?>

					<?php 
                }
                ?>



			</li>
			<?php 
            }
            ?>

		</ul>
		<?php 
            echo $after_widget;
            ?>

		<?php 
            // Reset the global $the_post as this query will have stomped on it
            wp_reset_postdata();
        }
        /*
        		$cache[$args['widget_id']] = ob_get_flush();
        		wp_cache_set( 'widget_recent_posts', $cache, 'widget' );
        */
    }
コード例 #2
0
/**
 *
 * Display meta line under post title
 *
 * @param string $type author|category|date
 */
function maxflat_display_meta_post($type = 'author')
{
    global $post;
    ?>


<p class="meta-line">
       <?php 
    echo maxflat_get_date();
    ?>

	<?php 
    $post_format = get_post_format($post->ID);
    $speacial_formats = array('gallery', 'video');
    if (in_array($post_format, $speacial_formats)) {
        ?>

		<span class="meta-label smartlib-postformat-info"><?php 
        maxflat_get_awesome_ico($post_format);
        ?>
 <?php 
        echo ucfirst($post_format);
        ?>
</span>
			<?php 
    }
    if ($type == 'author') {
        maxflat_author_line();
    } else {
        if ($type == 'category') {
            maxflat_category_line();
        }
    }
    ?>



</p>
		<?php 
}
コード例 #3
0
/**
 * The  template for displaying featured content
 */
?>

<div class="smartlib-featured-post-box">
    <article id="post-<?php 
the_ID();
?>
" <?php 
post_class();
?>
>
<?php 
maxflat_author_line();
?>

        <header class="entry-header">


            <h3 class="entry-title">
                <a href="<?php 
the_permalink();
?>
"
                   title="<?php 
echo esc_attr(sprintf(__('Permalink to %s', 'maxflat'), the_title_attribute('echo=0')));
?>
"
                   rel="bookmark"><?php