function widget($args, $instance) { /** * Default Values * 'title' => 'Most Commented Posts', 'show_count' => 5, 'show_excerpt' => false, 'show_thumb' => false, 'thumb_width' => 50, 'thumb_height' => 50, 'excerpt_length' => 55, 'hide_title' => false */ extract($args); extract($instance); $loop = get_posts(array('numberposts' => $show_count, 'orderby' => 'comment_count', 'post_type' => 'post', 'order' => 'DESC')); $html = ''; if ($loop) { /* Before widget (defined by themes). */ echo $before_widget; /* Title of widget (before and after defined by themes). */ if ($title) { echo $before_title . $title . $after_title; } $html .= '<ul class="feature-posts-list">'; global $post; foreach ($loop as $post) { setup_postdata($post); $post_excerpt = trim(strip_tags($post->post_excerpt)); $post_title = trim(strip_tags($post->post_title)); // cut to character limit $cut_excerpt = substr($post_excerpt, 0, $excerpt_length); if ($cut_excerpt != $post_excerpt) { // cut to last space $post_excerpt = substr($post_excerpt, 0, strrpos($post_excerpt, ' ')); } $html .= '<li>'; if ($show_thumb) { $html .= themify_get_image('ignore=true&w=' . $instance['thumb_width'] . '&h=' . $instance['thumb_height'] . '&before=<a href="' . get_permalink() . '">&after=</a>&class=post-img'); } if (!$hide_title) { $html .= '<a href="' . get_permalink() . '" class="feature-posts-title">' . get_the_title() . '</a>'; } if ($show_comment_count) { $comment_string = get_comments_number() > 1 ? __('comments', 'themify') : __('comment', 'themify'); $html .= '<br/><small>' . get_comments_number() . ' ' . $comment_string . '</small> <br />'; } if ($show_excerpt) { $the_excerpt = get_the_excerpt(); if ($excerpt_length != "") { // cut to character limit $the_excerpt = substr($the_excerpt, 0, $excerpt_length); // cut to last space $the_excerpt = substr($the_excerpt, 0, strrpos($the_excerpt, ' ')); } $html .= '<span class="post-excerpt">' . $the_excerpt . '</span>'; } $html .= '</li>'; wp_reset_postdata(); } $html .= '</ul>'; echo $html; echo $after_widget; } }
* @author Themify */ extract($settings, EXTR_SKIP); ?> <div class="gallery-showcase-image"> <img src="<?php echo wp_get_attachment_url($gallery_images[0]->ID); ?> " alt="" /> </div> <div class="gallery-images"> <?php $i = 0; foreach ($gallery_images as $image) { $link = wp_get_attachment_url($image->ID); $link_before = '' != $link ? sprintf('<a title="%s" href="%s">', esc_attr($image->post_title), esc_url($link)) : ''; $link_after = '' != $link ? '</a>' : ''; if ($this->is_img_php_disabled()) { $image = wp_get_attachment_image($image->ID, 'thumbnail'); } else { $image = wp_get_attachment_image_src($image->ID, 'full'); $image = themify_get_image("ignore=true&src={$image[0]}&w={$thumb_w_gallery}&h={$thumb_h_gallery}"); } echo $link_before . $image . $link_after; } // end loop ?> </div>
/** * Returns logo image. * Available filters: * 'themify_'.$location.'_logo_tag': filter the HTML tag used to wrap the text or image. * 'themify_logo_home_url': filter the home URL linked. * 'themify_'.$location.'_logo_html': filter the final HTML output to page. * @param string $location Logo location used as key to get theme setting values * @return string logo markup */ function themify_logo_image($location = 'site_logo', $cssid = 'site-logo') { if (themify_get('setting-' . $location) == 'image' && themify_check('setting-' . $location . '_image_value')) { $logo_tag = apply_filters('themify_' . $location . '_logo_tag', 'div'); $type = 'image'; } else { $logo_tag = apply_filters('themify_' . $location . '_logo_tag', 'h1'); $type = 'text'; } $html = '<' . $logo_tag . ' id="' . $cssid . '">'; $html .= '<a class="hidden-xs" href="' . apply_filters('themify_logo_home_url', "#header") . '" title="' . get_bloginfo('name') . '">'; if ('image' == $type) { $html .= themify_get_image("src=" . themify_get('setting-' . $location . '_image_value') . "&w=" . themify_get('setting-' . $location . '_width') . "&h=" . themify_get('setting-' . $location . '_height') . "&alt=" . urlencode(get_bloginfo('name'))); } else { $html .= get_bloginfo('name'); } $html .= '</a>'; $html .= '</' . $logo_tag . '>'; return apply_filters('themify_' . $location . '_logo_html', $html, $location, $logo_tag, $type); }
?> </ul> </div> <?php } else { // Check if user wants to use a common dimension or those defined in each highlight if ('yes' == $themify->use_original_dimensions) { // Save post id $post_id = get_the_ID(); // Set image width $themify->width = get_post_meta($post_id, 'image_width', true); // Set image height $themify->height = get_post_meta($post_id, 'image_height', true); } //otherwise display the featured image if ($post_image = themify_get_image('ignore=true&' . $themify->auto_featured_image . $themify->image_setting . "w=" . $themify->width . "&h=" . $themify->height)) { ?> <figure class="post-image <?php echo $themify->image_align; ?> "> <?php if ('yes' == $themify->unlink_image) { ?> <?php echo $post_image; ?> <?php } else { ?> <a href="<?php
/** * Returns logo image. * Available filters: * 'themify_'.$location.'_logo_tag': filter the HTML tag used to wrap the text or image. * 'themify_logo_home_url': filter the home URL linked. * 'themify_'.$location.'_logo_html': filter the final HTML output to page. * @param string $location Logo location used as key to get theme setting values * @param string $cssid ID attribute for the logo tag. * @return string logo markup */ function themify_logo_image($location = 'site_logo', $cssid = 'site-logo') { global $themify_customizer; $logo_tag = apply_filters('themify_' . $location . '_logo_tag', 'div'); $logo_mod = get_theme_mod($cssid . '_image'); $logo_is_image = themify_get('setting-' . $location) == 'image' && themify_check('setting-' . $location . '_image_value'); $html = '<' . $logo_tag . ' id="' . esc_attr($cssid) . '">'; if ($logo_is_image && empty($logo_mod)) { $html .= '<a href="' . esc_url(apply_filters('themify_logo_home_url', home_url())) . '" title="' . esc_attr(get_bloginfo('name')) . '">'; $type = $logo_is_image ? 'image' : 'text'; $site_name = get_bloginfo('name'); if ('image' == $type) { $html .= themify_get_image('ignore=true&src=' . themify_get('setting-' . $location . '_image_value') . '&w=' . themify_get('setting-' . $location . '_width') . '&h=' . themify_get('setting-' . $location . '_height') . '&alt=' . urlencode(get_bloginfo('name'))); $html .= isset($themify_customizer) ? '<span style="display: none;">' . esc_html($site_name) . '</span>' : ''; } else { $html .= isset($themify_customizer) ? '<span>' . esc_html($site_name) . '</span>' : esc_html($site_name); } $html .= '</a>'; } else { $type = 'customizer'; $html .= $themify_customizer->site_logo($cssid); } $html .= '</' . $logo_tag . '>'; return apply_filters('themify_' . $location . '_logo_html', $html, $location, $logo_tag, $type); }
/** * Returns the image for the portfolio slider * @param int $attachment_id Image attachment ID * @param int $width Width of the returned image * @param int $height Height of the returned image * @param string $size Size of the returned image * @return string * @since 1.1.0 */ function portfolio_image($attachment_id, $width, $height, $size = 'large') { $size = apply_filters('themify_portfolio_image_size', $size); if (themify_check('setting-img_settings_use')) { // Image Script is disabled, use WP image $html = wp_get_attachment_image($attachment_id, $size); } else { // Image Script is enabled, use it to process image $img = wp_get_attachment_image_src($attachment_id, $size); $html = themify_get_image('ignore=true&src=' . $img[0] . '&w=' . $width . '&h=' . $height); } return apply_filters('themify_portfolio_image_html', $html, $attachment_id, $width, $height, $size); }
$image_h = $img_h_slider; $image_title = isset($content['img_title_slider']) ? $content['img_title_slider'] : ''; $param_image_src = 'src=' . $image_url . '&w=' . $image_w . '&h=' . $image_h . '&alt=' . $image_title . '&ignore=true'; if ($this->is_img_php_disabled()) { // get image preset $preset = $image_size_slider != '' ? $image_size_slider : themify_get('setting-global_feature_size'); if (isset($_wp_additional_image_sizes[$preset]) && $image_size_slider != '') { $image_w = intval($_wp_additional_image_sizes[$preset]['width']); $image_h = intval($_wp_additional_image_sizes[$preset]['height']); } else { $image_w = $image_w != '' ? $image_w : get_option($preset . '_size_w'); $image_h = $image_h != '' ? $image_h : get_option($preset . '_size_h'); } $image = '<img src="' . $image_url . '" alt="' . $image_title . '" width="' . $image_w . '" height="' . $image_h . '">'; } else { $image = themify_get_image($param_image_src); } ?> <?php if (!empty($content['img_link_slider'])) { ?> <a href="<?php echo $content['img_link_slider']; ?> " alt="<?php echo $content['img_title_slider']; ?> "> <?php echo $image; ?>
if (themify_check('setting-header_slider_display') && themify_get('setting-header_slider_display') == "images") { $options = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'); foreach ($options as $option) { $option = 'setting-header_slider_images_' . $option; if (themify_check($option . '_image')) { echo '<li>'; $title = function_exists('icl_t') ? icl_t('Themify', $option . '_title', themify_get($option . '_title')) : (themify_check($option . '_title') ? themify_get($option . '_title') : ''); $image = themify_get($option . '_image'); $alt = $title ? $title : $image; if (themify_check($option . '_link')) { $link = themify_get($option . '_link'); $title_attr = $title ? "title='{$title}'" : ''; echo "<div class='slide-feature-image'><a href='{$link}' {$title_attr}>" . themify_get_image("src={$image}&ignore=true&w={$img_width}&h={$img_height}&alt={$alt}&class=feature-img") . '</a></div>'; echo $title ? '<div class="slide-content-wrap"><h3 class="slide-post-title"><a href="' . $link . '" ' . $title_attr . ' >' . $title . '</a></h3></div>' : ''; } else { echo '<div class="slide-feature-image">' . themify_get_image("src=" . $image . "&ignore=true&w={$img_width}&h={$img_height}&alt=" . $alt . "&class=feature-img") . '</div>'; echo $title ? '<div class="slide-content-wrap"><h3 class="slide-post-title">' . $title . '</h3></div>' : ''; } echo '</li>'; } } } else { query_posts($num_posts . $cat); if (have_posts()) { while (have_posts()) { the_post(); ?> <?php $link = themify_get_featured_image_link();
?> </figure> <?php } else { ?> <?php if ('yes' == $themify->use_original_dimensions) { $themify->width = themify_get('image_width'); $themify->height = themify_get('image_height'); } ?> <?php if ($post_image = themify_get_image('ignore=true&w=' . $themify->width . '&h=' . $themify->height)) { ?> <figure class="post-image <?php echo $themify->image_align; ?> "> <?php if ($themify->unlink_image != 'yes') { ?> <a href="<?php echo themify_get_featured_image_link(); ?> " class="themify-lightbox"> <?php
/** * Image Helper - Echoes themify_get_image * @param string $options Format string. */ function themify_image($options) { echo themify_get_image($options); }
<?php themify_before_post_image(); // Hook ?> <?php if (themify_get('video_url') != '') { ?> <?php global $wp_embed; echo $wp_embed->run_shortcode('[embed]' . themify_get('video_url') . '[/embed]'); ?> <?php } elseif ($post_image = themify_get_image($themify->auto_featured_image . $themify->image_setting . "w=" . $themify->width . "&h=" . $themify->height)) { ?> <figure class="post-image <?php echo $themify->image_align; ?> "> <?php if ('yes' == $themify->unlink_image) { ?> <?php echo $post_image; ?> <?php } else { ?>
<div class="related-posts"> <h4 class="related-title"><?php _e('Related Posts', 'themify'); ?> </h4> <?php while ($related->have_posts()) { $related->the_post(); ?> <article class="post type-post clearfix"> <?php if (!themify_check($key . '_hide_image') && has_post_thumbnail()) { ?> <?php if ($post_image = themify_get_image('setting=image_post_single&w=255&h=155&ignore=true')) { ?> <figure class="post-image clearfix"> <a href="<?php echo themify_get_featured_image_link(); ?> "><?php echo $post_image; themify_zoom_icon(); ?> </a> </figure> <?php } // if there's a featured image ?>
/** * 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', 'wrap' => 'no', 'excerpt_length' => '20', 'speed' => 'normal', 'slider_nav' => 'yes', 'limit' => '5', 'category' => '', 'image' => 'yes', 'image_w' => '240px', 'image_h' => '180px', 'more_text' => 'More...', 'title' => 'yes', 'display' => 'none', 'post_meta' => 'no', 'post_date' => 'no', 'width' => '', 'height' => '', 'class' => '', 'unlink_title' => 'no', 'unlink_image' => 'no'), $atts)); if ($wrap == "yes") { $wrapvar = "circular"; } if ($wrap == "no") { $wrapvar = "null"; } $numsldr = rand(0, 10000); global $wpdb, $post, $table_prefix; if ($category == 0) { $posts = get_posts(array('numberposts' => $limit)); } else { $arraycat = array($category); $listcat = $category; $arraycat = explode(',', $listcat); $posts = get_posts('category=' . $listcat . '&numberposts=' . $show); } if ($posts) { $postsliderstr = '<!-- shortcode post_slider --> <div id="post-slider-' . $numsldr . '" style="width: ' . $width . '; height: ' . $height . ';" class="shortcode clearfix post-slider ' . $class . '"> <ul class="slides">'; foreach ($posts as $post) { setup_postdata($post); global $more; $more = 0; $post_class = ""; if (themify_get('external_link') != '') { $thislink = themify_get('external_link'); } else { $thislink = get_permalink(); } foreach (get_post_class() as $postclass) { $post_class .= " " . $postclass; } //get_post_class() as $postclass $postsliderstr .= '<li><div class="slide-wrap ' . $post_class . '">'; if ($image == "yes") { if ('no' == $unlink_image) { $postsliderstr .= themify_get_image('ignore=true&w=' . $image_w . '&h=' . $image_h . '&alt=' . get_the_title() . '&before=<p class="post-image"><a href="' . $thislink . '">&after=</a></p>'); } else { $postsliderstr .= themify_get_image('ignore=true&w=' . $image_w . '&h=' . $image_h . '&alt=' . get_the_title() . '&before=<p class="post-image">&after=</p>'); } } //$image == "yes" if ($title == "yes") { if ('no' == $unlink_title) { $postsliderstr .= '<h3 class="post-title"><a href="' . get_permalink() . '">' . 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 ($post_meta == "yes") { $postsliderstr .= '<p class="post-meta"> <span class="post-author">' . get_the_author() . '</span> <span class="post-category">' . get_the_category_list(', ') . '</span>'; $num_comments = get_comments_number(); 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 ($display == "content") { $postsliderstr .= '<div class="post-content">' . themify_get_content($more_text) . '</div></div></li> '; } //$display == "content" if ($display == "excerpt") { $postsliderstr .= '<div class="post-content">' . themify_excerpt($excerpt_length) . '</div></div></li> '; } //$display == "excerpt" } $postsliderstr .= '</ul>'; if ($slider_nav == "yes") { $nextbutton = "<div>»</div>"; $prevbutton = "<div>«</div>"; } else { $nextbutton = "null"; $prevbutton = "null"; } //$slider_nav == "yes" $postsliderstr .= '</div><script type="text/javascript"> function carousel_callback_' . $numsldr . '(carousel) { // Disable autoscrolling if the user clicks the prev or next button. carousel.buttonNext.bind("click", function() { carousel.startAuto(0); }); carousel.buttonPrev.bind("click", function() { carousel.startAuto(0); }); // Pause autoscrolling if the user moves with the cursor over the clip. carousel.clip.hover(function() { carousel.stopAuto(); }, function() { carousel.startAuto(); }); } jQuery(document).ready(function($) { $("#post-slider-' . $numsldr . '").jcarousel({ wrap: "' . $wrapvar . '", auto: ' . $auto . ', visible: ' . $visible . ', scroll: ' . $scroll . ', animation: "' . $speed . '", buttonNextHTML: "' . $nextbutton . '", buttonPrevHTML: "' . $prevbutton . '", initCallback: carousel_callback_' . $numsldr . ' }); }); </script> <!-- /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; }
/** * Returns logo image * @param string * @return string */ function logo_image($location = 'site_logo') { $html = '<a href="' . home_url() . '" title="' . get_bloginfo('name') . '">'; $html .= themify_get_image("src=" . themify_get('setting-' . $location . '_image_value') . "&w=" . themify_get('setting-' . $location . '_width') . "&h=" . themify_get('setting-' . $location . '_height') . "&alt=" . urlencode(get_bloginfo('name'))); $html .= '</a>'; return apply_filters('themify_' . $location . '_image', $html); }
if (themify_get('video_url') != '') { ?> <figure class="post-image clearfix"> <?php global $wp_embed; echo $wp_embed->run_shortcode('[embed]' . themify_get('video_url') . '[/embed]'); ?> </figure> <?php } else { ?> <?php if ($post_image = themify_get_image($themify->auto_featured_image . $themify->image_setting . 'w=' . $themify->width . '&h=' . $themify->height)) { ?> <figure class="post-image <?php echo $themify->image_align; ?> clearfix"> <?php if ('yes' == $themify->unlink_image) { ?> <?php echo $post_image; ?> <?php } else {
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $show_count = isset($instance['show_count']) ? $instance['show_count'] : 10; $show_excerpt = isset($instance['show_excerpt']) ? $instance['show_excerpt'] : false; $show_thumb = isset($instance['show_thumb']) ? $instance['show_thumb'] : false; $thumb_width = isset($instance['thumb_width']) ? $instance['thumb_width'] : 50; $thumb_height = isset($instance['thumb_height']) ? $instance['thumb_height'] : 50; $excerpt_length = isset($instance['excerpt_length']) ? $instance['excerpt_length'] : 55; $hide_title = isset($instance['hide_title']) ? $instance['hide_title'] : false; $show_comment_count = isset($instance['show_comment_count']) ? $instance['show_comment_count'] : false; $loop = get_posts(array('numberposts' => $show_count, 'orderby' => 'comment_count', 'post_type' => 'post', 'order' => 'DESC', 'suppress_filters' => false)); if ($loop) { /* Before widget (defined by themes). */ echo $before_widget; /* Title of widget (before and after defined by themes). */ if ($title) { echo $args['before_title'] . $title . $args['after_title']; } echo '<ul class="feature-posts-list">'; global $post; foreach ($loop as $post) { setup_postdata($post); echo '<li>'; if ($show_thumb) { echo themify_get_image('ignore=true&w=' . $instance['thumb_width'] . '&h=' . $instance['thumb_height'] . '&before=<a href="' . esc_url(get_permalink()) . '">&after=</a>&class=post-img'); } if (!$hide_title) { echo '<a href="' . esc_url(get_permalink()) . '" class="feature-posts-title">' . get_the_title() . '</a>'; } if ($show_comment_count) { $comment_string = get_comments_number() > 1 ? __('comments', 'themify') : __('comment', 'themify'); echo '<br/><small>' . get_comments_number() . ' ' . $comment_string . '</small> <br />'; } if ($show_excerpt) { $the_excerpt = get_the_excerpt(); if ($excerpt_length != '') { // cut to character limit $the_excerpt = substr($the_excerpt, 0, $excerpt_length); // cut to last space $the_excerpt = substr($the_excerpt, 0, strrpos($the_excerpt, ' ')); } echo '<span class="post-excerpt">' . wp_kses_post($the_excerpt) . '</span>'; } echo '</li>'; wp_reset_postdata(); } echo '</ul>'; echo $after_widget; } }
/** * 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', 'wrap' => 'yes', 'excerpt_length' => '20', 'speed' => 'normal', 'slider_nav' => 'yes', 'pager' => 'yes', 'limit' => '5', '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' => 'thumbnail', 'post_type' => 'post', 'order' => 'DESC', 'orderby' => 'date', 'effect' => 'scroll'), $atts)); $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; } $numsldr = rand(0, 10000); $postsliderstr = ''; global $post; $query_args = array('numberposts' => $limit, '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' => 'category', 'field' => 'slug', 'terms' => $tax_query_terms)); } else { $query_args['tax_query'] = array(array('taxonomy' => 'category', 'field' => 'id', 'terms' => $tax_query_terms)); } } $posts = get_posts($query_args); $class .= ' effect-' . $effect; if ($posts) { $postsliderstr = '<!-- shortcode post_slider --> <div id="post-slider-' . $numsldr . '" style="width: ' . $width . '; height: ' . $height . ';" class="shortcode clearfix post-slider ' . $class . '"> <ul class="slides">'; foreach ($posts as $post) { setup_postdata($post); global $more; $more = 0; $post_class = ''; if (themify_get('external_link') != '') { $thislink = themify_get('external_link'); } else { $thislink = get_permalink(); } foreach (get_post_class() as $postclass) { $post_class .= " " . $postclass; } //get_post_class() as $postclass $postsliderstr .= '<li><div class="slide-wrap ' . $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('image_size=' . $image_size . '&ignore=true&w=' . $image_w . '&h=' . $image_h . '&alt=' . get_the_title() . '&before=<p class="post-image"><a href="' . $thislink . '">&after=</a></p>'); } else { $postsliderstr .= themify_get_image('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="' . get_permalink() . '">' . 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>'; $num_comments = get_comments_number(); 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">' . themify_get_content($more_text) . '</div></div></li> '; } //$display == "content" if ('excerpt' == $display) { $postsliderstr .= '<div class="post-content">' . themify_excerpt($excerpt_length) . '</div></div></li> '; } //$display == "excerpt" } $postsliderstr .= '</ul>'; if ('yes' == $slider_nav) { $nextbutton = '<div>»</div>'; $prevbutton = '<div>«</div>'; } else { $nextbutton = "null"; $prevbutton = "null"; } //$slider_nav == "yes" $postsliderstr .= '</div><script type="text/javascript"> jQuery(window).load(function() { jQuery("#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 . ', pauseDuration: ' . $auto . '*1000, duration: ' . $speed . '*1000 }, scroll: { items: ' . $scroll . ', duration: ' . $speed . '*1000, wipe: true, fx: "' . $effect . '" }, items: { visible: { min: 1, max: ' . $visible . ' }, width: 120 }, onCreate : function (){ jQuery(".post-slider").css( { "height": "auto", "visibility" : "visible" }); } }); }); </script> <!-- /shortcode post_slider -->'; wp_reset_postdata(); } //$posts return $postsliderstr; }
function themify_image_preview($data = array()) { global $config; $temp = get_data(); $output = '<div class="preset">'; if ($data['attr']['src'] != "") { $img_folders = array(0 => array('_a' => array('src' => $data['attr']['src']))); } else { $img_folders = $config['folders']['_c']['images']; } if (is_array($img_folders)) { if (isset($img_folders['_a']['src'])) { $folder = $folder['_a']['src']; if (is_dir(TEMPLATEPATH . '/' . $folder)) { if ($handle = opendir(TEMPLATEPATH . '/' . $folder)) { while (false !== ($file = readdir($handle))) { $ext = substr(strrchr($file, '.'), 1); if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png') { $fullpath = get_bloginfo('template_directory') . "/" . $folder . $file; $savedpath = $temp['styling-' . $data['category'] . '-' . $data['title'] . '-background_image-value-value']; if (trim($fullpath) == trim($savedpath)) { $output .= '<a href="#" title="' . $folder . $file . '"><span title="' . $folder . $file . '"></span>' . themify_get_image('w=50&h=50&src=' . $fullpath . '&alt=' . $fullpath . '&class=backgroundThumb selected') . '</a>'; } else { $output .= '<a href="#" title="' . $folder . $file . '"><span title="' . $folder . $file . '"></span>' . themify_get_image('w=50&h=50&src=' . $fullpath . '&alt=' . $fullpath . '&class=backgroundThumb') . '</a>'; } } } closedir($handle); } } } else { foreach ($img_folders as $folder) { $folder = $folder['_a']['src']; if (is_dir(TEMPLATEPATH . '/' . $folder)) { if ($handle = opendir(TEMPLATEPATH . '/' . $folder)) { while (false !== ($file = readdir($handle))) { $ext = substr(strrchr($file, '.'), 1); if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png') { $fullpath = get_bloginfo('template_directory') . "/" . $folder . $file; $savedpath = $temp['styling-' . $data['category'] . '-' . $data['title'] . '-background_image-value-value']; if (trim($fullpath) == trim($savedpath)) { $output .= '<a href="#" title="' . $folder . $file . '"><span title="' . $folder . $file . '"></span>' . themify_get_image('w=50&h=50&src=' . $fullpath . '&alt=' . $fullpath . '&class=backgroundThumb selected') . '</a>'; } else { $output .= '<a href="#" title="' . $folder . $file . '"><span title="' . $folder . $file . '"></span>' . themify_get_image('w=50&h=50&src=' . $fullpath . '&alt=' . $fullpath . '&class=backgroundThumb') . '</a>'; } } } closedir($handle); } } } } } $output .= '</div>'; return $output; }
$width = $img_w_slider; $height = $img_h_slider; $unlink_feat = $unlink_feat_img_slider == 'yes' ? true : false; $param_image = 'w=' . $width . '&h=' . $height . '&ignore=true'; if ($this->is_img_php_disabled()) { $param_image .= $image_size_slider != '' ? '&image_size=' . $image_size_slider : ''; } if (themify_get('external_link') != '') { $ext_link = themify_get("external_link"); } elseif (themify_get('lightbox_link') != '') { $ext_link = themify_get("lightbox_link") . '" class="lightbox" rel="prettyPhoto[slider]'; } else { $ext_link = get_permalink(); } if ($hide_feat_img_slider == '' || $hide_feat_img_slider == 'no') { $post_image = themify_get_image($param_image); if ($post_image || themify_check('video_url') == 1) { ?> <?php if (themify_check('video_url')) { global $wp_embed; $post_image = $wp_embed->run_shortcode('[embed]' . themify_get('video_url') . '[/embed]'); } ?> <?php themify_before_post_image(); // Hook ?> <figure class="slide-image"> <?php if ($unlink_feat) {
$height = $img_h_slider; $unlink_feat = $unlink_feat_img_slider == 'yes' ? true : false; $param_image = 'w=' . $width . '&h=' . $height . '&ignore=true'; if ($this->is_img_php_disabled()) { $param_image .= $image_size_slider != '' ? '&image_size=' . $image_size_slider : ''; } if ($hide_feat_img_slider == '' || $hide_feat_img_slider == 'no') { // Check if there is a video url in the custom field if (themify_get('video_url') != '') { global $wp_embed; themify_before_post_image(); // Hook echo $wp_embed->run_shortcode('[embed]' . esc_url(themify_get('video_url')) . '[/embed]'); themify_after_post_image(); // Hook } elseif ($post_image = themify_get_image($param_image)) { ?> <?php themify_before_post_image(); // Hook ?> <figure class="slide-image"> <?php if ($unlink_feat) { ?> <?php echo wp_kses_post($post_image); ?> <?php } else { ?>
exit; } // Exit if accessed directly /** * Template Gallery Lightboxed * * Access original fields: $mod_settings * @author Themify */ extract($settings, EXTR_SKIP); $alt = isset($gallery_images[0]->post_excerpt) ? $gallery_images[0]->post_excerpt : ''; /* if no thumbnail is set for the gallery, use the first image */ if (!isset($thumbnail_gallery)) { $thumbnail_gallery = wp_get_attachment_url($gallery_images[0]->ID); } $thumbnail = themify_get_image("ignore=true&src={$thumbnail_gallery}&w={$thumb_w_gallery}&h={$thumb_h_gallery}&alt={$alt}"); foreach ($gallery_images as $key => $image) { ?> <dl class="gallery-item" style="<?php echo 0 == $key ? '' : 'display: none;'; ?> "> <?php $link = wp_get_attachment_url($image->ID); $img = wp_get_attachment_image_src($image->ID, 'full'); if (!empty($link)) { echo '<dt class="gallery-icon"><a href="' . esc_url($link) . '" title="' . esc_attr($image->post_title) . '">'; } echo wp_kses_post(0 == $key ? $thumbnail : $img[1]); if (!empty($link)) { echo '</a></dt>';