<?php 
            if ($hide_post_title_slider == '' || $hide_post_title_slider == 'no') {
                ?>
					<?php 
                if ($unlink_post_title_slider == 'yes') {
                    ?>
						<h3 class="slide-title"><?php 
                    the_title();
                    ?>
</h3>
					<?php 
                } else {
                    ?>
						<h3 class="slide-title"><a href="<?php 
                    echo themify_get_featured_image_link();
                    ?>
" title="<?php 
                    the_title_attribute();
                    ?>
" <?php 
                    if ('yes' == $open_link_new_tab_slider) {
                        echo 'target="_blank"';
                    }
                    ?>
><?php 
                    the_title();
                    ?>
</a></h3>
					<?php 
                }
        function show_image($post_image)
        {
            global $themify;
            ?>

		<?php 
            if ('yes' == $themify->unlink_image) {
                ?>
			<?php 
                echo $post_image;
                ?>
		<?php 
            } else {
                ?>
			<a href="<?php 
                echo themify_get_featured_image_link();
                ?>
">
				<?php 
                if (themify_check('lightbox_icon')) {
                    ?>
					<span class="zoom"></span>
				<?php 
                }
                ?>
				<?php 
                echo $post_image;
                ?>
			</a>
		<?php 
            }
        }
示例#3
0
/** Themify Default Variables
 *  @var object */
global $themify;
?>

<article itemscope itemtype="http://schema.org/Article" id="highlight-<?php 
the_ID();
?>
" <?php 
post_class('post clearfix highlight-post');
?>
>

	<?php 
$link = themify_get_featured_image_link('no_permalink=true');
$before = '';
$after = '';
if ($link != '') {
    $before = '<a href="' . $link . '" title="' . get_the_title() . '">';
    $zoom_icon = themify_zoom_icon(false);
    $after = $zoom_icon . '</a>' . $after;
    $zoom_icon = '';
}
// Chart color
// Save post id
$post_id = get_the_ID();
$bar_percentage = get_post_meta($post_id, 'bar_percentage', true);
if ($bar_percentage) {
    // Key in theme settings
    $bar_color_key = 'styling-backgrounds-chart_bar_color-background_color-value-value';
/**
 * Create a slider with posts retrieved through get_posts
 * @param Object $atts
 * @param String $content
 * @return String
 */
function themify_shortcode_post_slider($atts, $content = null)
{
    extract(shortcode_atts(array('visible' => '1', 'scroll' => '1', 'auto' => '0', 'pause_hover' => 'no', 'wrap' => 'yes', 'excerpt_length' => '20', 'speed' => 'normal', 'slider_nav' => 'yes', 'pager' => 'yes', 'limit' => '5', 'offset' => '0', 'category' => '', 'image' => 'yes', 'image_w' => '240px', 'image_h' => '180px', 'more_text' => __('More...', 'themify'), 'title' => 'yes', 'display' => 'none', 'post_meta' => 'no', 'post_date' => 'no', 'width' => '100%', 'height' => 'auto', 'class' => '', 'unlink_title' => 'no', 'unlink_image' => 'no', 'image_size' => 'medium', 'post_type' => 'post', 'taxonomy' => 'category', 'order' => 'DESC', 'orderby' => 'date', 'effect' => 'scroll'), $atts, 'themify_post_slider'));
    $postsliderstr = '';
    global $post;
    $query_args = array('numberposts' => $limit, 'offset' => $offset, 'post_type' => $post_type, 'order' => $order, 'orderby' => $orderby, 'suppress_filters' => false, 'post__not_in' => !is_home() ? array(get_the_ID()) : array());
    if ('' != $category) {
        $tax_query_terms = explode(',', $category);
        if (preg_match('#[a-z]#', $category)) {
            $query_args['tax_query'] = array(array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $tax_query_terms));
        } else {
            $exclude = array_filter($tax_query_terms, 'themify_is_negative_number');
            $query_args['tax_query'] = array('relation' => 'AND', array('taxonomy' => $taxonomy, 'field' => 'id', 'terms' => array_filter($tax_query_terms, 'themify_is_positive_number')), array('taxonomy' => $taxonomy, 'field' => 'id', 'terms' => array_map('themify_make_absolute_number', $exclude), 'operator' => 'NOT IN'));
        }
    }
    $posts = get_posts(apply_filters('themify_post_slider_shortcode_query_args', $query_args, $atts));
    if ($posts) {
        switch ($speed) {
            case 'fast':
                $speed = '.5';
                break;
            case 'normal':
                $speed = '1';
                break;
            case 'slow':
                $speed = '4';
                break;
        }
        $class .= ' effect-' . $effect;
        $js_data['slider_nav'] = $slider_nav == 'yes' ? 1 : 0;
        $js_data['pager'] = $pager == 'yes' ? 1 : 0;
        $js_data['wrapvar'] = $wrap == 'yes' ? 1 : 0;
        $js_data['play'] = intval($auto);
        $js_data['pause_hover'] = $pause_hover == 'yes' ? 1 : 0;
        $js_data['speed'] = $speed;
        $js_data['scroll'] = $scroll;
        $js_data['effect'] = $effect;
        $js_data['visible'] = intval($visible);
        $js_data['numsldr'] = rand(0, 1011) . uniqid();
        $postsliderstr = '<!-- shortcode post_slider --> <div id="slider-' . esc_attr($js_data['numsldr']) . '" style="width: ' . esc_attr($width) . '; height: ' . esc_attr($height) . ';" class="shortcode clearfix post-slider ' . $class . '">
		<ul class="slides" data-slider="' . esc_attr(json_encode($js_data)) . '">';
        unset($js_data);
        foreach ($posts as $post) {
            setup_postdata($post);
            global $more;
            $more = 0;
            $post_class = '';
            foreach (get_post_class() as $postclass) {
                $post_class .= " " . $postclass;
            }
            //get_post_class() as $postclass
            $postsliderstr .= '<li><div  class="slide-wrap ' . esc_attr($post_class) . '">';
            if ('yes' == $image) {
                $video_url = themify_get('video_url');
                if ('' != $video_url) {
                    $postsliderstr .= '<div class="post-video">';
                    global $wp_embed;
                    $postsliderstr .= $wp_embed->run_shortcode('[embed]' . $video_url . '[/embed]');
                    $postsliderstr .= '</div>';
                } else {
                    if ('no' == $unlink_image) {
                        $postsliderstr .= themify_get_image(array('image_size=' => $image_size, 'ignore' => true, 'w' => $image_w, 'h' => $image_h, 'alt' => get_the_title(), 'before' => '<p class="post-image"><a href="' . themify_get_featured_image_link() . '">', 'after' => '</a></p>'));
                    } else {
                        $postsliderstr .= themify_get_image(array('image_size' => $image_size, 'ignore' => true, 'w' => $image_w, 'h' => $image_h, 'alt' => get_the_title(), 'before' => '<p class="post-image">', 'after' => '</p>'));
                    }
                }
            }
            //'yes' == $image
            if ('yes' == $title) {
                if ('no' == $unlink_title) {
                    $postsliderstr .= '<h3 class="post-title"><a href="' . themify_get_featured_image_link() . '">' . get_the_title() . '</a></h3>';
                } else {
                    $postsliderstr .= '<h3 class="post-title">' . get_the_title() . '</h3>';
                }
            }
            //$title == "yes"
            if ($post_date == "yes") {
                $postsliderstr .= '<p class="post-date">' . get_the_date() . '</p>';
            }
            //$post_date == "yes"
            if ('yes' == $post_meta) {
                $postsliderstr .= '<p class="post-meta">
					<span class="post-author">' . get_the_author() . '</span>
					<span class="post-category">' . get_the_category_list(', ') . '</span>';
                if (comments_open()) {
                    ob_start();
                    comments_popup_link('0', '1', '%', 'comments-link', '');
                    $write_comments = ob_get_contents();
                    ob_clean();
                } else {
                    $write_comments = '';
                }
                $postsliderstr .= '<span class="post-comment">' . $write_comments . '</span>';
                if (has_tag()) {
                    $postsliderstr .= '<span class="post-tag">' . get_the_tag_list('', ', ') . '</span>';
                }
                $postsliderstr .= '</p>';
            }
            //$post_meta == "yes"
            if ('content' == $display) {
                $postsliderstr .= '<div class="post-content">' . wp_kses_post(themify_get_content($more_text)) . '</div></div></li>';
            }
            //$display == "content"
            if ('excerpt' == $display) {
                $postsliderstr .= '<div class="post-content">' . wp_kses_post(themify_excerpt($excerpt_length)) . '</div></div></li>';
            }
            //$display == "excerpt"
        }
        $postsliderstr .= '</ul>';
        $postsliderstr .= '</div>
		<!-- /shortcode post_slider -->';
        wp_reset_postdata();
    }
    //$posts
    return $postsliderstr;
}
/**
 * Create a slider with posts retrieved through get_posts
 * @param Object $atts
 * @param String $content
 * @return String
 */
function themify_shortcode_post_slider($atts, $content = null)
{
    wp_enqueue_script('themify-carousel-js');
    extract(shortcode_atts(array('visible' => '1', 'scroll' => '1', 'auto' => '0', 'pause_hover' => 'no', 'wrap' => 'yes', 'excerpt_length' => '20', 'speed' => 'normal', 'slider_nav' => 'yes', 'pager' => 'yes', 'limit' => '5', 'offset' => '0', 'category' => '', 'image' => 'yes', 'image_w' => '240px', 'image_h' => '180px', 'more_text' => __('More...', 'themify'), 'title' => 'yes', 'display' => 'none', 'post_meta' => 'no', 'post_date' => 'no', 'width' => '', 'height' => '', 'class' => '', 'unlink_title' => 'no', 'unlink_image' => 'no', 'image_size' => 'medium', 'post_type' => 'post', 'taxonomy' => 'category', 'order' => 'DESC', 'orderby' => 'date', 'effect' => 'scroll'), $atts, 'themify_post_slider'));
    $wrapvar = 'false';
    if ('yes' == $wrap) {
        $wrapvar = 'true';
    }
    if ('0' == $auto) {
        $play = 'false';
    } else {
        $play = 'true';
    }
    switch ($speed) {
        case 'fast':
            $speed = '.5';
            break;
        case 'normal':
            $speed = '1';
            break;
        case 'slow':
            $speed = '4';
            break;
    }
    $pause_hover = $pause_hover == 'yes' ? 'true' : 'false';
    $numsldr = rand(0, 10000);
    $postsliderstr = '';
    global $post;
    $query_args = array('numberposts' => $limit, 'offset' => $offset, 'post_type' => $post_type, 'order' => $order, 'orderby' => $orderby, 'suppress_filters' => false, 'post__not_in' => array(get_the_ID()));
    if ('' != $category) {
        $tax_query_terms = explode(',', $category);
        if (preg_match('#[a-z]#', $category)) {
            $query_args['tax_query'] = array(array('taxonomy' => $taxonomy, 'field' => 'slug', 'terms' => $tax_query_terms));
        } else {
            $exclude = array_filter($tax_query_terms, 'themify_is_negative_number');
            $query_args['tax_query'] = array('relation' => 'AND', array('taxonomy' => $taxonomy, 'field' => 'id', 'terms' => array_filter($tax_query_terms, 'themify_is_positive_number')), array('taxonomy' => $taxonomy, 'field' => 'id', 'terms' => array_map('themify_make_absolute_number', $exclude), 'operator' => 'NOT IN'));
        }
    }
    $posts = get_posts($query_args);
    $class .= ' effect-' . $effect;
    if ($posts) {
        $postsliderstr = '<!-- shortcode post_slider --> <div id="post-slider-' . esc_attr($numsldr) . '" style="width: ' . esc_attr($width) . '; height: ' . esc_attr($height) . ';" class="shortcode clearfix post-slider ' . $class . '">
		<ul class="slides">';
        foreach ($posts as $post) {
            setup_postdata($post);
            global $more;
            $more = 0;
            $post_class = '';
            foreach (get_post_class() as $postclass) {
                $post_class .= " " . $postclass;
            }
            //get_post_class() as $postclass
            $postsliderstr .= '<li><div  class="slide-wrap ' . esc_attr($post_class) . '">';
            if ('yes' == $image) {
                $video_url = themify_get('video_url');
                if ('' != $video_url) {
                    $postsliderstr .= '<div class="post-video">';
                    global $wp_embed;
                    $postsliderstr .= $wp_embed->run_shortcode('[embed]' . $video_url . '[/embed]');
                    $postsliderstr .= '</div>';
                } else {
                    if ('no' == $unlink_image) {
                        $postsliderstr .= themify_get_image(array('image_size=' => $image_size, 'ignore' => true, 'w' => $image_w, 'h' => $image_h, 'alt' => get_the_title(), 'before' => '<p class="post-image"><a href="' . themify_get_featured_image_link() . '">', 'after' => '</a></p>'));
                    } else {
                        $postsliderstr .= themify_get_image(array('image_size' => $image_size, 'ignore' => true, 'w' => $image_w, 'h' => $image_h, 'alt' => get_the_title(), 'before' => '<p class="post-image">', 'after' => '</p>'));
                    }
                }
            }
            //'yes' == $image
            if ('yes' == $title) {
                if ('no' == $unlink_title) {
                    $postsliderstr .= '<h3 class="post-title"><a href="' . themify_get_featured_image_link() . '">' . get_the_title() . '</a></h3>';
                } else {
                    $postsliderstr .= '<h3 class="post-title">' . get_the_title() . '</h3>';
                }
            }
            //$title == "yes"
            if ($post_date == "yes") {
                $postsliderstr .= '<p class="post-date">' . get_the_date() . '</p>';
            }
            //$post_date == "yes"
            if ('yes' == $post_meta) {
                $postsliderstr .= '<p class="post-meta">
					<span class="post-author">' . get_the_author() . '</span>
					<span class="post-category">' . get_the_category_list(', ') . '</span>';
                if (comments_open()) {
                    ob_start();
                    comments_popup_link('0', '1', '%', 'comments-link', '');
                    $write_comments = ob_get_contents();
                    ob_clean();
                } else {
                    $write_comments = '';
                }
                $postsliderstr .= '<span class="post-comment">' . $write_comments . '</span>';
                if (has_tag()) {
                    $postsliderstr .= '<span class="post-tag">' . get_the_tag_list('', ', ') . '</span>';
                }
                $postsliderstr .= '</p>';
            }
            //$post_meta == "yes"
            if ('content' == $display) {
                $postsliderstr .= '<div class="post-content">' . wp_kses_post(themify_get_content($more_text)) . '</div></div></li>
';
            }
            //$display == "content"
            if ('excerpt' == $display) {
                $postsliderstr .= '<div class="post-content">' . wp_kses_post(themify_excerpt($excerpt_length)) . '</div></div></li>
';
            }
            //$display == "excerpt"
        }
        $postsliderstr .= '</ul>';
        $postsliderstr .= '</div>
		<script type="text/javascript">
		(function($){
			$(window).load(function() {
				var $slider_slides = $("#post-slider-' . $numsldr . ' .slides");
				$("#post-slider-' . $numsldr . ' .slides").carouFredSel({
			responsive: true,';
        if ('yes' == $slider_nav) {
            $postsliderstr .= '
				prev: "#post-slider-' . $numsldr . ' .carousel-prev",
				next: "#post-slider-' . $numsldr . ' .carousel-next",';
        }
        if ('yes' == $pager) {
            $postsliderstr .= '
				pagination: "#post-slider-' . $numsldr . ' .carousel-pager",';
        }
        $postsliderstr .= '
			circular: ' . $wrapvar . ',
			infinite: ' . $wrapvar . ',
			auto: {
				play : ' . $play . ',
				timeoutDuration: ' . $auto . '*1000,
				duration: ' . $speed . '*1000,
				pauseOnHover: ' . $pause_hover . '
			},
			swipe: true,
			scroll: {
				items: ' . $scroll . ',
				duration: ' . $speed . '*1000,
				fx: "' . $effect . '"
			},
			items: {
				visible: {
					min: 1,
					max: ' . $visible . '
				},
				width: 120
			},
			onCreate : function (){
				jQuery(".post-slider").css( {
					"height": "auto",
					"visibility" : "visible"
				});
			}
		});
			
				var tscpsDidResize = false;
				$(window).on("resize", function() {
					tscpsDidResize = true;
	});
				setInterval(function() {
					if ( tscpsDidResize ) {
						tscpsDidResize = false;

						$(".slides").each(function(){
							var heights = [],
								newHeight,
								$self = $(this);
							$self.find("li").each( function() {
								heights.push( $(this).outerHeight() );
							});
							newHeight = Math.max.apply( Math, heights );
							$self.outerHeight( newHeight );
							$(".caroufredsel_wrapper").outerHeight( newHeight );
						});

					}
				}, 500);
			});
		})(jQuery);
	</script> <!-- /shortcode post_slider -->';
        wp_reset_postdata();
    }
    //$posts
    return $postsliderstr;
}