<?php
/*
===================================================================================================
WARNING! DO NOT EDIT THIS FILE OR ANY TEMPLATE FILES IN THIS THEME!

To make it easy to update your theme, you should not edit this file. Instead, you should create a
Child Theme first. This will ensure your template changes are not lost when updating the theme.

You can learn more about creating Child Themes here: http://codex.wordpress.org/Child_Themes

You have been warned! :)
===================================================================================================
*/
?>
<?php

$slide_settings = get_option('ct_slide_settings');
isset($slide_settings['orderby']) ? $orderby = $slide_settings['orderby'] : $orderby = null;
isset($slide_settings['order']) ? $order = $slide_settings['order'] : $order = null;
isset($slide_settings['active_slide_tags']) ? $tags = $slide_settings['active_slide_tags'] : $tags = null;
isset($slide_settings['slide_limit']) ? $num = $slide_settings['slide_limit'] : $num = null;

if(empty($orderby)) $orderby = 'date';
if(empty($order)) $order = 'DESC';

global $post;

if($orderby == 'views'):
	$args=array(
		'post_type' => 'ct_slide',
		'post_status' => 'publish',
		'posts_per_page' => $num,
		'meta_key' => 'Views',
		'orderby' => 'meta_value_num',
		'order' => $order,
		'slide_tag' => $tags,
	);
else:
	$args=array(
		'post_type' => 'ct_slide',
		'post_status' => 'publish',
		'posts_per_page' => $num,
		'orderby' => $orderby,
		'order' => $order,
		'slide_tag' => $tags,
	);
endif;

$query = null;
$query = new WP_Query($args);

?>
		<div id="ribbon" class="home">
			<div class="container_12 grid-container">
				<div class="grid_12 grid-100">
					<div class="slide_frame<?php if($query->have_posts()): else: echo ' empty'; endif; ?>">
						<div id="slider">
							<div class="slide_holder">
								<div class="mask">
									<ul>
<?php

if($query->have_posts()): while($query->have_posts()) : $query->the_post();

$sl_tagline = get_post_meta($post->ID, '_ct_sl_tagline', true);
$sl_linkurl = get_post_meta($post->ID, '_ct_sl_linkurl', true);
$sl_disable_text = get_post_meta($post->ID, '_ct_sl_disable_text', true);

$img_attr = array(
	'alt'	=> trim(strip_tags($post->post_title)),
	'title'	=> '',
);

?>
										<li>
											<div class="slide">
<?php if($sl_linkurl): ?><a href="<?php echo $sl_linkurl; ?>"><?php endif; ?>
												<?php echo get_the_post_thumbnail($post->ID, 'slide', $img_attr); ?>
<?php if($sl_linkurl): ?></a><?php endif; ?>
<?php if($sl_disable_text != 'true'): ?>
												<div class="slide_content_holder">
													<div class="slide_content">
<?php if($sl_linkurl): ?><a href="<?php echo $sl_linkurl; ?>"><?php endif; ?>
														<h2 class="title"><span><?php the_title(); ?></span></h2>
<?php if($sl_linkurl): ?></a><?php endif; ?>
<?php if($sl_tagline): ?>
<?php if($sl_linkurl): ?><a href="<?php echo $sl_linkurl; ?>"><?php endif; ?>
														<h3 class="subtitle"><span><?php echo $sl_tagline; ?></span></h3>
<?php if($sl_linkurl): ?></a><?php endif; ?>
<?php endif; ?>
													</div>
												</div>
<?php endif; ?>
											</div>
										</li>
<?php endwhile; endif; wp_reset_query(); ?>
									</ul>
								</div>
							</div>
							<div class="pag_box hide-on-mobile">
								<div class="pag_frame"></div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>