EstudioJuridicoAlmagro_Web/www/slider.php
2013-03-01 18:06:10 +00:00

227 lines
7.5 KiB
PHP

<?php
global $post;
$slider_effect = wpv_post_default('slider-effect', 'header-slider-effect');
$slider_style = get_slider_design($slider_effect);
$width = (int)wpv_get_option('content-width');
if($slider_style == 'side-caption') {
$width -= 300;
}
if($slider_style == 'peek') {
$width -= 180;
}
?>
<div id="header-slider-caption-wrapper"></div>
<div id="header-slider" class="invisible">
<?php
$query = array(
'post_type' => 'slideshow',
'posts_per_page' => -1,
'order' => 'ASC',
'orderby' => 'menu_order',
);
global $post;
$cats = get_post_meta(get_the_id(), 'slider_categories', true);
if(!empty($cats)) {
$query['tax_query'] = array(
array(
'taxonomy' => 'slideshow_category',
'field' => 'slug',
'terms' => unserialize($cats),
'operator' => 'IN',
)
);
$query['taxonomy'] = 'slideshow_category';
}
query_posts($query);
while(have_posts()): the_post();
$image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full');
$image = $image[0];
$background = get_post_meta(get_the_id(), 'background', true);
$href = get_post_meta(get_the_id(), 'slide-link', true);
$link_target = get_post_meta(get_the_id(), 'slide-link-target', true);
if(!empty($href)) {
$href = "data-href='$href' data-target='$link_target'";
} else {
$href = '';
}
$style = '';
if(!empty($background)) {
$style .= "background:$background; ";
}
$style = "data-style='$style'";
if(get_post_meta(get_the_id(), 'slide-content-is', true) == 'caption'):
$content = get_the_content();
$caption_id = '';
if(!empty($content)) {
$caption_id = '#caption-'.get_the_id();
$captions[] = array(
'id' => 'caption-'.get_the_id(),
'content' => apply_filters('the_content', $content),
'helper1' => apply_filters('the_content', get_post_meta(get_the_id(), 'caption-helper-1', true)),
'helper2' => apply_filters('the_content', get_post_meta(get_the_id(), 'caption-helper-2', true)),
);
}
?>
<img src="<?php echo $image?>" data-thumb="<?php echo $image?>" alt="<?php echo $caption_id?>" class="wpv-slide" <?php echo "$style $href"?>/>
<?php else: ?>
<div class="wpv-slide" <?php echo "$style $href"?> data-thumb="<?php echo $image?>">
<div style="width:<?php echo $width ?>px"><?php echo apply_filters('the_content', get_the_content()) ?></div>
</div>
<?php endif ?>
<?php
endwhile;
wp_reset_query();
if(wpv_get_option('enable-featured-posts')):
$query = array(
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'featured',
'value' => 'true',
)
),
);
// query not ready
global $post;
query_posts($query);
while(have_posts()): the_post(); ?>
<?php
$caption_id = '#caption-'.get_the_id();
$captions[] = array(
'id' => 'caption-'.get_the_id(),
'content' => '',
'helper1' => '<div class="slide-post-pad">'.get_the_excerpt().'</div>',
'helper2' => '<a href="'.get_permalink().'" title="'.get_the_title().'">'.get_the_title().'</a>',
);
?>
<?php if(has_post_format('video')): ?>
<div class="wpv-slide" data-caption="<?php echo $caption_id?>">
<?php wpv_post_video(wpv_get_slider_width(), wpv_get_option('header-slider-height')); ?>
</div>
<?php else:
$image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full');
$image = $image[0];
?>
<img src="<?php echo $image?>" data-thumb="<?php echo $image?>" alt="<?php echo $caption_id?>" data-href="<?php the_permalink() ?>" class="wpv-slide"/>
<?php endif ?>
<?php
endwhile;
wp_reset_query();
$query = array(
'post_type' => 'portfolio',
'orderby'=>'menu_order',
'order'=>'ASC',
'posts_per_page' => -1,
'meta_query' => array(
array(
'key' => 'featured',
'value' => 'true',
)
),
);
query_posts($query);
$size = array(0.7*940-8, wpv_get_option('header-slider-height'));
$moretext = __('Read more', 'wpv');
while(have_posts()): the_post();
?>
<?php
$caption_id = '#caption-'.get_the_id();
$captions[] = array(
'id' => 'caption-'.get_the_id(),
'content' => '',
'helper1' => '<div class="slide-post-pad">'.get_the_excerpt().'</div>',
'helper2' => '<a href="'.get_permalink().'" title="'.get_the_title().'">'.get_the_title().'</a>',
);
$image = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full');
$image = $image[0];
?>
<img src="<?php echo $image?>" data-thumb="<?php echo $image?>" alt="<?php echo $caption_id?>" data-href="<?php the_permalink() ?>" class="wpv-slide" />
<?php
endwhile;
wp_reset_query();
endif;
?>
</div>
<div class="hidden">
<?php if(is_array($captions)): ?>
<?php foreach($captions as $caption): ?>
<div id="<?php echo $caption['id']?>" class="wpv-caption-origin">
<?php
if($slider_style == 'navigation-preview') {
$caption = array(
'content' => $caption['helper2'],
'helper1' => $caption['content'],
'helper2' => $caption['helper1']
);
}
?>
<div class="main-caption sub-caption"><?php echo $caption['content']?></div>
<?php if(!empty($caption['helper1'])): ?>
<div class="helper-caption-1 sub-caption"><?php echo $caption['helper1']?></div>
<?php endif ?>
<?php if(!empty($caption['helper2'])): ?>
<div class="helper-caption-2 sub-caption"><?php echo $caption['helper2']?></div>
<?php endif ?>
</div>
<?php endforeach ?>
<?php endif ?>
</div>
<script>
jQuery(function($) {
$('#header-slider').wpvSlider({
captionContainer : "#header-slider-caption-wrapper",
height: <?php wpvge('header-slider-height')?>,
width: <?php echo $width ?>,
pause_time: <?php wpvge('header-slider-pausetime')?>,
animation_time: <?php wpvge('header-slider-animationtime')?>,
effect: '<?php echo $slider_effect?>',
auto_direction: '<?php wpvge('header-slider-direction')?>',
caption_opacity: <?php wpvge('header-slider-captionopacity')?>,
expand: <?php echo intval( wpv_post_default('slider-fullwidth', 'has-fullwidth-slider') == 'true' )?>,
prev_text: '<?php wpvge('header-slider-prevtext')?>',
next_text: '<?php wpvge('header-slider-nexttext')?>',
autoHeight: <?php echo intval(wpv_get_option('header-slider-autoheight'))?>,
pause_on_hover: <?php echo intval(wpv_get_option('header-slider-pauseonhover'))?>,
resizing: '<?php echo wpv_get_option('header-slider-resizing')?>',
show_arrows: false,
effect_settings: {
easing: '<?php wpvge('header-slider-easing')?>',
waveDuration: <?php wpvge('header-slider-animationtime')?>,
subslideDuration: <?php wpvge('header-slider-subslideduration')?>,
waveType: '<?php wpvge('header-slider-wavetype')?>',
visibleGrid: <?php echo intval(wpv_get_option('header-slider-visiblegrid'))?>,
rows: <?php echo intval(wpv_get_option('header-slider-rows'))?>,
cols: <?php echo intval(wpv_get_option('header-slider-cols'))?>,
caption_animation_time: <?php echo intval(wpv_get_option('header-slider-captiontime'))?>,
caption_queue: true
}
});
});
</script>