Ejemplo n.º 1
0
    /**
     * Add slideshow functionality
     *
     * Displays a slideshow according to the parameters set in the argument array.
     *
     * @since PressWork 1.0
     */
    function pw_slideshow($args = '')
    {
        global $wp_scripts;
        $defaults = array('type' => 'scrollerota', 'cat' => '', 'postnum' => 4, 'width' => pw_theme_option('content_width'), 'height' => 260, 'excerpt' => 35);
        $r = wp_parse_args($args, $defaults);
        extract($r, EXTR_SKIP);
        $name = $r['type'];
        $wp_scripts->in_footer[] = 'pw_' . $name . '_js';
        $wp_scripts->queue[] = 'pw_' . $name . '_js';
        $wp_scripts->groups['pw_' . $name . '_js'] = 1;
        if (!empty($r['cat'])) {
            $featuredcat = $r['cat'];
            $posts = array("posts_per_page" => $r['postnum'], "cat" => $featuredcat, "ignore_sticky_posts" => 1);
        } else {
            $posts = array("posts_per_page" => $r['postnum'], "ignore_sticky_posts" => 1);
        }
        $featured = new WP_Query();
        $featured->query($posts);
        ?>
	<div id="<?php 
        echo $r['type'];
        ?>
" class="pw-slideshow" style="height: <?php 
        echo $r['height'];
        ?>
px;">
		<div class="slideshow-content" style="height: <?php 
        echo $r['height'];
        ?>
px;">
			<ul class="images">
			<?php 
        while ($featured->have_posts()) {
            $featured->the_post();
            ?>
 
				<li>
				<?php 
            if (function_exists('has_post_thumbnail') && has_post_thumbnail()) {
                echo '<a href="' . get_permalink() . '">';
                the_post_thumbnail('full');
                echo '</a>';
            }
            ?>
				</li>
			<?php 
        }
        ?>
			</ul>
			<ul class="text">
			<?php 
        while ($featured->have_posts()) {
            $featured->the_post();
            ?>
 
				<li>
				<?php 
            if ($r['type'] == "faderota") {
                echo '<header><h4><a href="' . get_permalink() . '">' . esc_attr(get_the_title()) . '</a></h4></header>';
            } else {
                echo '<header><h4><a href="' . get_permalink() . '">' . esc_attr(get_the_title()) . '</a></h4></header>';
                echo pw_excerpt($r['excerpt']);
                ?>
					<footer><a href="<?php 
                the_permalink();
                ?>
" class="readmore"><?php 
                _e('Read more', "presswork");
                ?>
</a></footer>
				<?php 
            }
            ?>
				</li>
			<?php 
        }
        ?>
			</ul>
		</div><!-- end .slideshow-content -->
	</div><!-- end #slideshow -->
	<?php 
    }
Ejemplo n.º 2
0
function pw_columns_post_content($r)
{
    ?>
    <div class="storycontent">
		<?php 
    if (function_exists('has_post_format') && !is_singular()) {
        $format = get_post_format();
        if (empty($format) || has_post_format('image')) {
            if (has_post_format('image')) {
                $size = 'full';
            } else {
                $size = array($r['img_w'], $r['img_h']);
            }
            if (function_exists('has_post_thumbnail') && has_post_thumbnail() && $r['images'] == 1) {
                echo '<a href="' . get_permalink() . '" class="image-anchor">';
                the_post_thumbnail($size, array('class' => $r['img_float']));
                echo '</a>';
            } else {
                if (has_post_format('image')) {
                    the_content();
                }
            }
            if (empty($format)) {
                if ($r['text'] == "content") {
                    if ($r['readmore'] == 1) {
                        the_content(__('Read more &rarr;', "presswork"));
                    } else {
                        the_content('');
                    }
                } else {
                    pw_excerpt($r['excerpt_length']);
                    if ($r['readmore'] == 1) {
                        echo '<a href="' . get_permalink() . '" class="more-link">' . __('Read more &rarr;', "presswork") . '</a>';
                    }
                }
            }
        } elseif (has_post_format('gallery')) {
            // new gallery post format
            global $post;
            $images = get_children(array('post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999));
            if ($images) {
                $total_images = count($images);
                $image = array_shift($images);
                $image_img_tag = wp_get_attachment_image($image->ID, 'full');
                ?>
				<a class="gallery-thumb  img-shadow alignnone" href="<?php 
                the_permalink();
                ?>
"><?php 
                echo $image_img_tag;
                ?>
</a>
				<p class="gallery-text clearfix fl"><em><?php 
                printf(_n('This gallery contains <a %1$s>%2$s photo &rarr;</a>', 'This gallery contains <a %1$s>%2$s photos &rarr;</a>', $total_images, "presswork"), 'href="' . get_permalink() . '" title="' . sprintf(esc_attr__('Permalink to %s', "presswork"), the_title_attribute('echo=0')) . '" rel="bookmark"', number_format_i18n($total_images));
                ?>
</em>
				</p>
				<?php 
            }
            ?>
				<?php 
        } else {
            // new aside || link || audio || video || image post format
            echo '<div class="pformat clearfix">';
            if ($r['readmore'] == 1) {
                the_content(__('Read more &rarr;', "presswork"));
            } else {
                the_content('');
            }
            echo '</div>';
        }
    }
    ?>
    </div>
	<?php 
}