Skip to content

Instantly share code, notes, and snippets.

@catchthemes
Created March 15, 2014 11:11
Show Gist options
  • Save catchthemes/9565356 to your computer and use it in GitHub Desktop.
Save catchthemes/9565356 to your computer and use it in GitHub Desktop.
Catch Everest Pro Theme: Image Slider, making custom link compatible to qtranslate plugin
<?php
/**
* Template for Featued Image Slider
*
* To override this in a child theme
* simply create your own catcheverest_image_sliders(), and that function will be used instead.
*
* @uses catcheverest_header action to add it in the header
* @since Catch Everest Pro 1.0
*/
function catcheverest_image_sliders() {
delete_transient( 'catcheverest_image_sliders' );
global $catcheverest_options_settings;
$options = $catcheverest_options_settings;
$more_tag_text = sprintf( __( '%s', 'catcheverest' ) , $options[ 'more_tag_text' ] );
if( ( !$catcheverest_image_sliders = get_transient( 'catcheverest_image_sliders' ) ) && !empty( $options[ 'featured_image_slider_image' ] ) ) {
echo '<!-- refreshing cache -->';
$catcheverest_image_sliders = '
<div id="main-slider" class="container">
<section class="featured-slider">';
for ( $i=0; $i<=$options[ 'slider_qty' ]; $i++ ) {
//Adding in Classes for Display blok and none
if ( $i == 1 ) { $classes = 'image imageid-'.$i.' hentry slides displayblock'; } else { $classes = 'image imageid-'.$i.' hentry slides displaynone'; }
//Check Image Not Empty to add in the slides
if ( !empty ( $options[ 'featured_image_slider_image' ][ $i ] ) ) {
//Checking Link and target
if ( !empty ( $options[ 'featured_image_slider_link' ][ $i ] ) ) {
if ( function_exists( 'qtrans_convertURL' ) ) {
$link = qtrans_convertURL($options[ 'featured_image_slider_link' ][ $i ]);
}
else {
$link = $options[ 'featured_image_slider_link' ][ $i ];
}
//Checking Link Target
if ( !empty ( $options[ 'featured_image_slider_base' ][ $i ] ) ) {
$target = '_blank';
} else {
$target = '_self';
}
}
else {
$link = '';
$target = '';
}
//Checking Title
if ( !empty ( $options[ 'featured_image_slider_title' ][ $i ] ) ) {
$imagetitle = sprintf( __( '%s', 'catcheverest' ) , $options[ 'featured_image_slider_title' ][ $i ] );
if ( !empty ( $options[ 'featured_image_slider_link' ][ $i ] ) ) {
$title = '<header class="entry-header"><h1 class="entry-title"><a title="' . $imagetitle . '" href="'.$link.'" target="'.$target.'"><span>' . $imagetitle . '</span></a></h1></header>';
}
else {
$title = '<header class="entry-header"><h1 class="entry-title"><span>' . $imagetitle . '</span></h1></header>';
}
}
else {
$title = '';
$imagetitle = '';
}
//Checking Image Link
if ( !empty ( $options[ 'featured_image_slider_link' ][ $i ] ) ) {
$image = '<a title="' . $imagetitle . '" href="' . $link . '" target="' . $target . '"><img title="' . $imagetitle . '" alt="' . $imagetitle . '" class="wp-post-image" src="'.$options[ 'featured_image_slider_image' ][ $i ].'" /></a>';
}
else {
$image = '<span class="no-img-link"><img title="' . $imagetitle . '" alt="' . $imagetitle . '" class="wp-post-image" src="'.$options[ 'featured_image_slider_image' ][ $i ].'" /></span>';
}
//Checking Content
if ( !empty ( $options[ 'featured_image_slider_content' ][ $i ] ) ) {
$imagecontent = sprintf( __( '%s', 'catcheverest' ) , $options[ 'featured_image_slider_content' ][ $i ] );
if ( !empty ( $options[ 'featured_image_slider_link' ][ $i ] ) ) {
$content = '<div class="entry-content">' . $imagecontent . ' <a href="' . $link . '" class="more-link" target="' . $target . '">' . $more_tag_text . '</a></div>';
}
else {
$content = '<div class="entry-content">' . $imagecontent . '</div>';
}
}
else {
$content = '';
}
//Content Opening and Closing
if ( !empty ( $options[ 'featured_image_slider_title' ][ $i ] ) || !empty ( $options[ 'featured_image_slider_content' ][ $i ] ) ) {
$contentopening = '<div class="entry-container">';
$contentclosing = '</div>';
}
else {
$contentopening = '';
$contentclosing = '';
}
$catcheverest_image_sliders .= '
<article class="'.$classes.'">
<figure class="slider-image">'.$image.'</figure>'
.$contentopening.
$title.$content
.$contentclosing.'
</article><!-- .slides -->';
}
}
$catcheverest_image_sliders .= '
</section>
<div id="slider-nav">
<a class="slide-previous">&lt;</a>
<a class="slide-next">&gt;</a>
</div>
<div id="controllers"></div>
</div><!-- #main-slider -->';
set_transient( 'catcheverest_image_sliders', $catcheverest_image_sliders, 86940 );
}
echo $catcheverest_image_sliders;
} // catcheverest_image_sliders
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment