Last active
December 12, 2015 05:28
-
-
Save BoweFrankema/4721564 to your computer and use it in GitHub Desktop.
Only show slider box for logged in users.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Template Name: Features or Category Slider | |
* | |
* This template either displays Slides taken from the "Features" custom post type. | |
* Or Loops through posts from a certain category. This is based on the theme options set by | |
* the user. | |
* | |
* @author Bowe Frankema <[email protected]> | |
* @link http://shop.presscrew.com/ | |
* @copyright Copyright (C) 2010-2011 Bowe Frankema | |
* @license http://www.gnu.org/licenses/gpl.html GPLv2 or later | |
*/ | |
?> | |
<?php | |
// Show slides from the Features custom post type by default | |
if ( infinity_option_get( 'balance-flex-slider' ) == 1 ): | |
?> | |
<div class="flex-container"> | |
<div class="flexslider"> | |
<ul class="slides"> | |
<?php | |
$captions = array(); | |
$tmp = $wp_query; | |
$wp_query = new WP_Query('post_type=features&order=ASC'); | |
if($wp_query->have_posts()) : | |
while($wp_query->have_posts()) : | |
$wp_query->the_post(); | |
$captions[] = ''.get_the_excerpt().''; | |
$sliderheight = infinity_option_get( 'balance-flex-slider-height' ); | |
$sliderwidth = infinity_option_get( 'balance-flex-slider-width' ); | |
?> | |
<!-- Loop through slides --> | |
<li> | |
<?php /* video added? */ if ( get_post_meta( $post->ID, '_balance_video_url', true) && get_post_meta( $post->ID, '_balance_video_provider',true) == "vimeo" ) : ?> | |
<iframe src="http://player.vimeo.com/video/<?php echo get_post_meta($post->ID, '_balance_video_url', true) ?>?title=0&byline=0&portrait=0" width="980" height="360" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe> | |
<p id="hover-button" class="button black" id="<?php the_post_name(); ?>"> | |
<a href="<?php the_permalink(); ?>"> | |
<span><?php the_title_attribute(); ?></span> | |
</a> | |
</p> | |
<?php elseif ( get_post_meta( $post->ID, '_balance_video_url', true) && get_post_meta( $post->ID, '_balance_video_provider',true) == "youtube" ) : ?> | |
<iframe width="980" height="360" src="http://www.youtube.com/embed/<?php echo get_post_meta($post->ID, '_balance_video_url', true) ?>" frameborder="0" allowfullscreen> </iframe> | |
<p id="hover-button" class="button black" id="<?php the_post_name(); ?>"> | |
<a href="<?php the_permalink(); ?>"> | |
<span><?php the_title_attribute(); ?></span> | |
</a> | |
</p> | |
<?php else: ?> | |
<!-- Image --> | |
<?php if(has_post_thumbnail()) :?> | |
<a href="<?php the_permalink(); ?>"> | |
<?php the_post_thumbnail( array( 'width' => $sliderwidth, 'height' => $sliderheight, 'crop' => true ) ) ?> | |
</a> | |
<!-- Caption --> | |
<p class="flex-caption" id="<?php the_post_name(); ?>"> | |
<a href="<?php the_permalink(); ?>"> | |
<span><?php the_title_attribute(); ?></span> | |
</a> | |
</p> | |
<?php else :?> | |
<img src="<?php echo get_template_directory_uri()?>/assets/images/no-slides.jpg"/> | |
<?php endif;?> | |
<?php endif; ?> | |
</li> | |
<?php endwhile; else: ?> | |
<!-- Fallback to default slide if no features are present --> | |
<li> | |
<img src="<?php echo get_template_directory_uri()?>/assets/images/no-slides.jpg"/> | |
</li> | |
<?php | |
endif; | |
// reset query | |
$wp_query = $tmp; | |
?> | |
</ul> | |
</div> | |
</div> | |
<?php endif; // end custom post type slider ?> | |
<?php if ( infinity_option_get( 'balance-flex-slider' ) == 2 ): ?> | |
<div class="flex-container"> | |
<div class="flexslider"> | |
<ul class="slides"> | |
<!-- Load custom Post Type --> | |
<?php | |
$cat = infinity_option_get( 'balance-flex-slider-category' ); | |
$quantity = infinity_option_get( 'balance-flex-slider-amount' ); | |
$captions = array(); | |
$tmp = $wp_query; | |
$wp_query = new WP_Query('cat='.$cat.'&order=ASC&posts_per_page='.$quantity.''); | |
if($wp_query->have_posts()) : | |
while($wp_query->have_posts()) : | |
$wp_query->the_post(); | |
$captions[] = '<h3>'.get_the_title($post->ID).'</h3><p>'.get_the_excerpt().'</p>'; | |
$sliderheight = infinity_option_get( 'balance-flex-slider-height' ); | |
$sliderwidth = infinity_option_get( 'balance-flex-slider-width' ); | |
?> | |
<!-- Loop through slides --> | |
<li> | |
<?php /* video added? */ if ( get_post_meta( $post->ID, '_balance_video_url', true) && get_post_meta( $post->ID, '_balance_video_provider',true) == "vimeo" ) : ?> | |
<iframe src="http://player.vimeo.com/video/<?php echo get_post_meta($post->ID, '_balance_video_url', true) ?>?title=0&byline=0&portrait=0" width="980" height="360" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe> | |
<p id="hover-button" class="button black" id="<?php the_post_name(); ?>"> | |
<a href="<?php the_permalink(); ?>"> | |
<span><?php the_title_attribute(); ?></span> | |
</a> | |
</p> | |
<?php elseif ( get_post_meta( $post->ID, '_balance_video_url', true) && get_post_meta( $post->ID, '_balance_video_provider',true) == "youtube" ) : ?> | |
<iframe width="980" height="360" src="http://www.youtube.com/embed/<?php echo get_post_meta($post->ID, '_balance_video_url', true) ?>" frameborder="0" allowfullscreen> </iframe> | |
<p id="hover-button" class="button black" id="<?php the_post_name(); ?>"> | |
<a href="<?php the_permalink(); ?>"> | |
<span><?php the_title_attribute(); ?></span> | |
</a> | |
</p> | |
<?php else: ?> | |
<!-- Image --> | |
<?php if(has_post_thumbnail()) :?> | |
<a href="<?php the_permalink(); ?>"> | |
<?php the_post_thumbnail( array( 'width' => $sliderwidth, 'height' => $sliderheight, 'crop' => true ) ) ?> | |
</a> | |
<!-- Caption --> | |
<p class="flex-caption" id="<?php the_post_name(); ?>"> | |
<a href="<?php the_permalink(); ?>"> | |
<span><?php the_title_attribute(); ?></span> | |
</a> | |
</p> <?php else :?> | |
<img src="<?php echo get_template_directory_uri()?>/assets/images/no-slides.jpg"/> | |
<?php endif;?> | |
<?php endif; ?> | |
</li> | |
<?php endwhile; else: ?> | |
<!-- Fallback to default slide if posts are found --> | |
<li> | |
<img src="<?php echo get_template_directory_uri()?>/assets/images/no-slides.jpg"/> | |
</li> | |
<?php | |
endif; | |
// reset query | |
$wp_query = $tmp; | |
?> | |
</ul> | |
</div> | |
</div> | |
<?php endif; // end custom post type slider ?> | |
<?php if (!is_user_logged_in()) { ?> | |
<?php | |
// is slider title set? | |
if ( infinity_option_get( 'balance-flex-slider-title' ) ): | |
// show homepage intro text if set ?> | |
<div class="callout-box"> | |
<h2><?php echo infinity_option_get( 'balance-flex-slider-title' ); ?></h2> | |
<?php if ( infinity_option_get( 'balance-flex-slider-button' ) == 1 ): ?> | |
<?php | |
if ( infinity_option_get( 'balance-flex-slider-button-type' ) == 0 ): | |
$text = infinity_option_get( 'balance-flex-slider-button-text' ); | |
$href = ( function_exists( 'bp_signup_slug' ) ) ? bp_get_signup_slug() : wp_login_url() . '?action=register'; | |
elseif ( infinity_option_get( 'balance-flex-slider-button-type' ) == 1 ) : | |
$text = infinity_option_get( 'balance-flex-slider-button-text' ); | |
$href = infinity_option_get( 'balance-flex-slider-button-url' ); | |
endif; | |
?> | |
<div class="callout-button-wrap"> | |
<a id="callout-button" class="button <?php echo infinity_option_get( 'balance-button-color' ); ?>" title="<?php echo $text; ?>" href="<?php echo $href; ?>"> | |
<span><?php echo $text; ?> → </span></a> | |
</div> | |
<?php endif; ?> | |
</div> | |
<?php | |
endif; | |
?> | |
<?php } ?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment