コード例 #1
0
ファイル: functions.php プロジェクト: TheRojam/raindrops
    function raindrops_tile($args = array())
    {
        global $query_string;
        $defaults = array('posts_per_page' => 3, 'numberposts' => -1, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'post__not_in' => get_option('sticky_posts'), 'raindrops_tile_col' => 3);
        $args = wp_parse_args($args, $defaults);
        $args['paged'] = get_query_var('page');
        if (!isset($args['paged'])) {
            $args['paged'] = 1;
        }
        if ($args['paged'] > 0) {
            $args['offset'] = ($args['paged'] - 1) * $args['posts_per_page'];
        } else {
            $args['offset'] = 0;
        }
        $raindrops_posts = get_posts($args);
        $raindrops_html_page = '<li><a href="%1$s" class="%2$s"><span class="%3$st">%4$s</span></a></li>';
        if (!empty($raindrops_posts)) {
            ?>
<div id="portfolio" class="portfolio column-<?php 
            echo $args['raindrops_tile_col'];
            ?>
"><?php 
            do_action('raindrops_tile_pre');
            raindrops_loop_title();
            $raindrops_loop_number = 1;
            foreach ($raindrops_posts as $post) {
                setup_postdata($post);
                $raindrops_loop_class = raindrops_loop_class($raindrops_loop_number, $post->ID);
                printf('<li class="loop-%1$s%2$s" %3$s>', trim($raindrops_loop_class[0]), apply_filters('raindrops_tile_class', ' ' . trim($raindrops_loop_class[1]), $post->ID), apply_filters('raindrops_tile_style', $raindrops_loop_class[2], $post->ID));
                $raindrops_loop_number++;
                ?>
<div id="post-<?php 
                echo $post->ID;
                ?>
"><<?php 
                raindrops_doctype_elements('div', 'article');
                ?>
 id="post-tile-<?php 
                echo $post->ID;
                ?>
" <?php 
                raindrops_post_class('', $post->ID);
                ?>
 >
					<h2 class="entry-title"><a href="<?php 
                echo get_permalink($post->ID);
                ?>
">
							<?php 
                $title = get_the_title($post->ID);
                $title = wp_html_excerpt($title, apply_filters('raindrops_tile_title_length', 40), apply_filters('raindrops_tile_title_more', '...'));
                echo raindrops_fallback_title($title, $post->ID);
                ?>
</a></h2>
					<div class="posted-on">
						<?php 
                raindrops_posted_on();
                ?>
					</div>
					<div class="entry-content clearfix">
						<a href="<?php 
                echo get_comments_link($post->ID);
                ?>
" class="raindrops-comment-link"><span class="raindrops-comment-string point"></span><em><?php 
                esc_html_e('Comment', 'raindrops');
                ?>
</em></a>
					</div>
					<div class="entry-meta">
						<?php 
                edit_post_link(esc_html__('Edit', 'raindrops') . raindrops_link_unique('Post', $post->ID), '<span class="edit-link">', '</span>', $post->ID);
                ?>
					</div>
					<br class="clear" />
					</<?php 
                raindrops_doctype_elements('div', 'article');
                ?>
></div>
				</li>
			<?php 
            }
            //foreach( $raindrops_posts as $post )
            ?>
			</ul>
			<br class="clear" />
			<?php 
            $html = '';
            if (0 == $args['paged']) {
                if (is_front_page()) {
                    $url = esc_url(add_query_arg('page', 2)) . '#portfolio';
                    $html = '<li><a href="' . esc_url($url) . '" title="page 2" class="portfolio-page2">' . esc_html__('Page', 'raindrops') . '2</a></li>';
                } else {
                    $url = esc_url(add_query_arg('page', 2)) . '#portfolio';
                    $html = '<li><a href="' . esc_url($url) . '" title="page 2" class="portfolio-page2">' . esc_html__('Page', 'raindrops') . '2</a></li>';
                }
            } elseif ($args['paged'] > 0) {
                $page = $args['paged'] + 1;
                $url = esc_url(add_query_arg('page', $page)) . '#portfolio';
                $html = sprintf($raindrops_html_page, esc_url($url), 'portfolio-next portfolio-' . $page, 'portfolio-nav-next', esc_html__('Page', 'raindrops') . ' ' . $page);
            }
            $url = esc_url(add_query_arg('page', $args['paged'])) . '#portfolio';
            $raindrops_page_for_posts = get_option('page_for_posts');
            $raindrops_html_page = '<li><a href="%1$s" class="%2$s"><span class="%3$st">%4$s</span></a></li>';
            if ($args['post_type'] == 'post' && $raindrops_page_for_posts) {
                $html .= sprintf($raindrops_html_page, esc_url(get_permalink($raindrops_page_for_posts)), 'portfolio-link-to-page-for-posts', 'link-to-page-title', get_the_title($raindrops_page_for_posts));
            }
            if (2 == $args['paged']) {
                $page = $args['paged'] - 1;
                $url = esc_url(add_query_arg('page', $page)) . '#portfolio';
                $html .= sprintf($raindrops_html_page, esc_url($url), 'portfolio-prev portfolio-home', 'portfolio-nav-prev', __('Portfolio Home', 'raindrops'));
            } elseif ($args['paged'] > 2) {
                $page = $args['paged'];
                $page = $page - 1;
                $url = esc_url(add_query_arg('page', $page)) . '#portfolio';
                $html .= sprintf($raindrops_html_page, esc_url($url), 'portfolio-prev portfolio-' . $page, 'portfolio-nav-prev', esc_html__('Page', 'raindrops') . ' ' . $page);
            }
            echo apply_filters('raindrops_portfolio_nav', sprintf('<div class="portfolio-nav"><ul>%1$s</ul></div>', $html));
        } else {
            //! empty( $raindrops_posts )
            ?>
<div  id="post-<?php 
            the_ID();
            ?>
"><<?php 
            raindrops_doctype_elements('div', 'article');
            ?>
 <?php 
            raindrops_post_class('no-portfolio');
            ?>
 ><?php 
            $url = remove_query_arg('page', get_permalink());
            $raindrops_html_page = '<p style="text-align:center;"><a href="%1$s" class="%2$s" ><span class="%3$st">%4$s</span></a></p>';
            if (preg_match('!page=!', $query_string)) {
                ?>
<h3 style="text-align:center" class="h1 portfolio-navigation-last">End</h3><?php 
                echo apply_filters('raindrops_portfolio_nav', sprintf($raindrops_html_page, esc_url($url), 'portfolio-home', 'portfolio-home-text', esc_html__('Portfolio Home', 'raindrops')));
            }
            echo apply_filters('raindrops_portfolio_nav', sprintf($raindrops_html_page, home_url(), 'portfolio blog-home-link', 'portfolio-nav', esc_html__('Home', 'raindrops')));
            ?>
</<?php 
            raindrops_doctype_elements('div', 'article');
            ?>
></div><?php 
        }
        wp_reset_postdata();
        do_action('raindrops_tile_after');
        ?>
		</div>
		<?php 
    }
コード例 #2
0
ファイル: search.php プロジェクト: TheRojam/raindrops
        }
        ?>
                                    <div class="entry-content clearfix">

                                        <?php 
        raindrops_prepend_entry_content();
        raindrops_entry_content();
        ?>
                                        <br class="clear" />
                                        <?php 
        raindrops_append_entry_content();
        ?>
                                    </div>
                                    <div class="entry-meta"><?php 
        if ('after' == raindrops_warehouse('raindrops_posted_on_position')) {
            raindrops_posted_on();
        }
        if ('after' == raindrops_warehouse('raindrops_posted_in_position')) {
            raindrops_posted_in();
        }
        ?>
</div>
                                    <br class="clear" />
								</<?php 
        raindrops_doctype_elements('div', 'article');
        ?>
>
                                </div>
                            </li>

                        <?php