/** @see WP_Widget::widget */ function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $category = apply_filters('widget_category', $instance['category']); $post_format = apply_filters('widget_post_format', $instance['post_format']); $linktext = apply_filters('widget_linktext', $instance['linktext']); $linkurl = apply_filters('widget_linkurl', $instance['linkurl']); $count = apply_filters('widget_count', $instance['count']); $excerpt_count = apply_filters('widget_excerpt_count', $instance['excerpt_count']); ?> <?php echo $before_widget; ?> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <?php if ($post_format == 'post-format-standard') { $args = array('showposts' => $count, 'category_name' => $category, 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-aside', 'post-format-gallery', 'post-format-link', 'post-format-image', 'post-format-quote', 'post-format-audio', 'post-format-video'), 'operator' => 'NOT IN'))); } else { $args = array('showposts' => $count, 'category_name' => $category, 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array($post_format)))); } ?> <?php $wp_query = new WP_Query($args); ?> <ul class="latestpost"> <?php if ($wp_query->have_posts()) { while ($wp_query->have_posts()) { $wp_query->the_post(); ?> <li class="clearfix"> <time datetime="<?php the_time('Y-m-d\\TH:i'); ?> "><?php the_time('j'); ?> <span class="month"><?php the_time('M'); ?> </span></time> <h4><a href="<?php the_permalink(); ?> " rel="bookmark" title="<?php _e('Permanent Link to', 'theme1762'); ?> <?php the_title_attribute(); ?> "><?php the_title(); ?> </a></h4> <?php if ($excerpt_count != "") { ?> <div class="excerpt"> <?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt, $excerpt_count); ?> </div> <?php } ?> </li> <?php } ?> </ul> <?php } ?> <?php $wp_query = null; $wp_query = $temp; ?> <!-- Link under post cycle --> <?php if ($linkurl != "") { ?> <a href="<?php echo $linkurl; ?> " class="button"><?php echo $linktext; ?> </a> <?php } ?> <?php echo $after_widget; ?> <?php }
function posts_grid_shortcode($atts, $content = null, $shortcodename = '') { extract(shortcode_atts(array('type' => 'post', 'category' => '', 'custom_category' => '', 'tag' => '', 'columns' => '3', 'rows' => '3', 'order_by' => 'date', 'order' => 'DESC', 'thumb_width' => '370', 'thumb_height' => '250', 'meta' => '', 'excerpt_count' => '15', 'link' => 'yes', 'link_text' => __('Read more', CHERRY_PLUGIN_DOMAIN), 'custom_class' => ''), $atts)); $spans = $columns; $rand = rand(); // columns switch ($spans) { case '1': $spans = 'span12'; break; case '2': $spans = 'span6'; break; case '3': $spans = 'span4'; break; case '4': $spans = 'span3'; break; case '6': $spans = 'span2'; break; } // check what order by method user selected switch ($order_by) { case 'date': $order_by = 'post_date'; break; case 'title': $order_by = 'title'; break; case 'popular': $order_by = 'comment_count'; break; case 'random': $order_by = 'rand'; break; } // check what order method user selected (DESC or ASC) switch ($order) { case 'DESC': $order = 'DESC'; break; case 'ASC': $order = 'ASC'; break; } // show link after posts? switch ($link) { case 'yes': $link = true; break; case 'no': $link = false; break; } global $post; global $my_string_limit_words; $numb = $columns * $rows; // WPML filter $suppress_filters = get_option('suppress_filters'); $args = array('post_type' => $type, 'category_name' => $category, $type . '_category' => $custom_category, 'tag' => $tag, 'numberposts' => $numb, 'orderby' => $order_by, 'order' => $order, 'suppress_filters' => $suppress_filters); $posts = get_posts($args); $i = 0; $count = 1; $output_end = ''; $countul = 0; if ($numb > count($posts)) { $output_end = '</ul>'; } $output = '<ul class="posts-grid row-fluid unstyled ' . $custom_class . ' ul-item-' . $countul . '">'; foreach ($posts as $j => $post) { $post_id = $posts[$j]->ID; //Check if WPML is activated if (defined('ICL_SITEPRESS_VERSION')) { global $sitepress; $post_lang = $sitepress->get_language_for_element($post_id, 'post_' . $type); $curr_lang = $sitepress->get_current_language(); // Unset not translated posts if ($post_lang != $curr_lang) { unset($posts[$j]); } // Post ID is different in a second language Solution if (function_exists('icl_object_id')) { $posts[$j] = get_post(icl_object_id($posts[$j]->ID, $type, true)); } } setup_postdata($posts[$j]); $excerpt = get_the_excerpt(); $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'full'); $url = $attachment_url['0']; $image = aq_resize($url, $thumb_width, $thumb_height, true); $mediaType = get_post_meta($post_id, 'tz_portfolio_type', true); $prettyType = 0; if ($count > $columns) { $count = 1; $countul++; $output .= '<ul class="posts-grid row-fluid unstyled ' . $custom_class . ' ul-item-' . $countul . '">'; } $output .= '<li class="' . $spans . ' list-item-' . $count . '">'; if (has_post_thumbnail($post_id) && $mediaType == 'Image') { $prettyType = 'prettyPhoto-' . $rand; $output .= '<figure class="featured-thumbnail thumbnail">'; $output .= '<a href="' . $url . '" title="' . get_the_title($post_id) . '" rel="' . $prettyType . '">'; $output .= '<img src="' . $image . '" alt="' . get_the_title($post_id) . '" />'; $output .= '<span class="zoom-icon"></span></a></figure>'; } elseif ($mediaType != 'Video' && $mediaType != 'Audio') { $thumbid = 0; $thumbid = get_post_thumbnail_id($post_id); $images = get_children(array('orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post_id, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => -1)); if ($images) { $k = 0; //looping through the images foreach ($images as $attachment_id => $attachment) { $prettyType = "prettyPhoto-" . $rand . "[gallery" . $i . "]"; //if( $attachment->ID == $thumbid ) continue; $image_attributes = wp_get_attachment_image_src($attachment_id, 'full'); // returns an array $img = aq_resize($image_attributes[0], $thumb_width, $thumb_height, true); //resize & crop img $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); $image_title = $attachment->post_title; if ($k == 0) { if (has_post_thumbnail($post_id)) { $output .= '<figure class="featured-thumbnail thumbnail">'; $output .= '<a href="' . $image_attributes[0] . '" title="' . get_the_title($post_id) . '" rel="' . $prettyType . '">'; $output .= '<img src="' . $image . '" alt="' . get_the_title($post_id) . '" />'; } else { $output .= '<figure class="featured-thumbnail thumbnail">'; $output .= '<a href="' . $image_attributes[0] . '" title="' . get_the_title($post_id) . '" rel="' . $prettyType . '">'; $output .= '<img src="' . $img . '" alt="' . get_the_title($post_id) . '" />'; } } else { $output .= '<figure class="featured-thumbnail thumbnail" style="display:none;">'; $output .= '<a href="' . $image_attributes[0] . '" title="' . get_the_title($post_id) . '" rel="' . $prettyType . '">'; } $output .= '<span class="zoom-icon"></span></a></figure>'; $k++; } } elseif (has_post_thumbnail($post_id)) { $prettyType = 'prettyPhoto-' . $rand; $output .= '<figure class="featured-thumbnail thumbnail">'; $output .= '<a href="' . $url . '" title="' . get_the_title($post_id) . '" rel="' . $prettyType . '">'; $output .= '<img src="' . $image . '" alt="' . get_the_title($post_id) . '" />'; $output .= '<span class="zoom-icon"></span></a></figure>'; } } else { // for Video and Audio post format - no lightbox $output .= '<figure class="featured-thumbnail thumbnail"><a href="' . get_permalink($post_id) . '" title="' . get_the_title($post_id) . '">'; $output .= '<img src="' . $image . '" alt="' . get_the_title($post_id) . '" />'; $output .= '</a></figure>'; } $output .= '<div class="clear"></div>'; $output .= '<h5><a href="' . get_permalink($post_id) . '" title="' . get_the_title($post_id) . '">'; $output .= get_the_title($post_id); $output .= '</a></h5>'; if ($meta == 'yes') { // begin post meta $output .= '<div class="post_meta">'; // post category $output .= '<span class="post_category">'; if ($type != '' && $type != 'post') { $terms = get_the_terms($post_id, $type . '_category'); if ($terms && !is_wp_error($terms)) { $out = array(); $output .= '<em>Posted in </em>'; foreach ($terms as $term) { $out[] = '<a href="' . get_term_link($term->slug, $type . '_category') . '">' . $term->name . '</a>'; } $output .= join(', ', $out); } } else { $categories = get_the_category($post_id); if ($categories) { $out = array(); $output .= '<em>Posted in </em>'; foreach ($categories as $category) { $out[] = '<a href="' . get_category_link($category->term_id) . '" title="' . $category->name . '">' . $category->cat_name . '</a> '; } $output .= join(', ', $out); } } $output .= '</span>'; // post date $output .= '<span class="post_date">'; $output .= '<time datetime="' . get_the_time('Y-m-d\\TH:i:s', $post_id) . '">' . get_the_date() . '</time>'; $output .= '</span>'; // post author $output .= '<span class="post_author">'; $output .= '<em> by </em>'; $output .= '<a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_the_author_meta('display_name') . '</a>'; $output .= '</span>'; // post comment count $num = 0; $queried_post = get_post($post_id); $cc = $queried_post->comment_count; if ($cc == $num || $cc > 1) { $cc = $cc . ' Comments'; } else { $cc = $cc . ' Comment'; } $permalink = get_permalink($post_id); $output .= '<span class="post_comment">'; $output .= '<a href="' . $permalink . '" class="comments_link">' . $cc . '</a>'; $output .= '</span>'; $output .= '</div>'; // end post meta } $output .= cherry_get_post_networks(array('post_id' => $post_id, 'display_title' => false, 'output_type' => 'return')); if ($excerpt_count >= 1) { $output .= '<p class="excerpt">'; $output .= my_string_limit_words($excerpt, $excerpt_count); $output .= '</p>'; } if ($link) { $output .= '<a href="' . get_permalink($post_id) . '" class="btn btn-primary" title="' . get_the_title($post_id) . '">'; $output .= $link_text; $output .= '</a>'; } $output .= '</li>'; if ($j == count($posts) - 1) { $output .= $output_end; } if ($count % $columns == 0) { $output .= '</ul><!-- .posts-grid (end) -->'; } $count++; $i++; } // end for wp_reset_postdata(); // restore the global $post variable $output = apply_filters('cherry_plugin_shortcode_output', $output, $atts, $shortcodename); return $output; }
function shortcode_carousel($atts, $content = null) { extract(shortcode_atts(array( 'title' => '', 'num' => '8', 'type' => '', 'thumb' => 'true', 'thumb_width' => '220', 'thumb_height' => '180', 'more_text_single' => theme_locals('read_more'), 'category' => '', 'custom_category' => '', 'excerpt_count' => '12', 'date' => '', 'author' => '', 'min_items' => '3', 'spacer' => '18', 'custom_class' => '' ), $atts)); $template_url = get_stylesheet_directory_uri(); // check what type of post user selected switch ($type) { case 'blog': $type_post = ''; break; case 'portfolio': $type_post = 'portfolio'; break; case 'testimonial': $type_post = 'testi'; break; } $output = '<div class="carousel-wrap '.$custom_class.'">'; if ($title != '') { $output .= '<h2>'.$title.'</h2>'; } $output .= '<div id="carousel-'. $type .'" class="es-carousel-wrapper">'; $output .= '<div class="es-carousel">'; $output .= '<ul class="es-carousel_list unstyled">'; global $post; global $my_string_limit_words; $args = array( 'post_type' => $type_post, 'category_name' => $category, $type_post . '_category' => $custom_category, 'numberposts' => $num, 'orderby' => 'post_date', 'order' => 'DESC' ); $latest = get_posts($args); $i = 0; foreach($latest as $post) { setup_postdata($post); $excerpt = get_the_excerpt(); $format = get_post_format(); $attachment_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); $url = $attachment_url['0']; $image = aq_resize($url, $thumb_width, $thumb_height, true); $link_format_url = get_post_meta(get_the_ID(), 'tz_link_url', true); $output .= '<li class="es-carousel_li '.$format.'">'; if ($thumb == 'true') { if (has_post_thumbnail($post->ID) && $format == 'image') { $prettyType = 'prettyPhoto'; $output .= '<figure class="featured-thumbnail">'; $output .= '<a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$image.'" alt="'.get_the_title($post->ID).'" />'; $output .= '</a></figure>'; } elseif ( $format != 'video' && $format != 'audio') { $thumbid = 0; $thumbid = get_post_thumbnail_id($post->ID); $images = get_children( array( 'orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => -1 ) ); if ( $images ) { $k = 0; //looping through the images foreach ( $images as $attachment_id => $attachment ) { //if( $attachment->ID == $thumbid ) continue; $image_attributes = wp_get_attachment_image_src( $attachment_id, 'full' ); // returns an array $img = aq_resize($image_attributes[0], $thumb_width, $thumb_height, true); //resize & crop img $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); $image_title = $attachment->post_title; if ( $k == 0 ) { $output .= '<figure class="featured-thumbnail">'; $output .= '<a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$img.'" alt="'.get_the_title($post->ID).'" />'; } else { $output .= '<figure class="featured-thumbnail" style="display:none;">'; $output .= '<a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$img.'" alt="'.get_the_title($post->ID).'" />'; } $output .= '</a></figure>'; $k++; } } elseif (has_post_thumbnail($post->ID)) { $output .= '<figure class="featured-thumbnail">'; $output .= '<a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$image.'" alt="'.get_the_title($post->ID).'" />'; $output .= '</a></figure>'; } /*else { // empty_featured_thumb.gif - for post without featured thumbnail $output .= '<figure class="featured-thumbnail">'; $output .= '<a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$template_url.'/images/empty_thumb.gif" alt="'.get_the_title($post->ID).'" />'; $output .= '</a></figure>'; }*/ } else { if (has_post_thumbnail($post->ID)) { // for Video and Audio post format - no lightbox $output .= '<figure class="featured-thumbnail"><a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$image.'" alt="'.get_the_title($post->ID).'" />'; $output .= '</a></figure>'; } /*else { // empty_featured_thumb.gif - for post without featured thumbnail $output .= '<figure class="featured-thumbnail">'; $output .= '<a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$template_url.'/images/empty_thumb.gif" alt="'.get_the_title($post->ID).'" />'; $output .= '</a></figure>'; }*/ } } $output .= '<div class="desc">'; if ($date == "yes") { $output .= '<time datetime="'.get_the_time('Y-m-d\TH:i:s', $post->ID).'">' .get_the_time('M', $post->ID). ' <span>'.get_the_time('d', $post->ID).'</span></time>'; } if ($author == "yes") { $output .= '<em class="author">, '.theme_locals("by").' <a href="'.get_author_posts_url(get_the_author_meta( 'ID' )).'">'.get_the_author_meta('display_name').'</a></em>'; } //Link format if ($format == "link") { $output .= '<h5><a href="'.$link_format_url.'" title="'.get_the_title($post->ID).'">'; $output .= get_the_title($post->ID); $output .= '</a></h5>'; //Other formats } else { $output .= '<h5><a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= get_the_title($post->ID); $output .= '</a></h5>'; } if($excerpt_count >= 1){ $output .= '<p class="excerpt">'; $output .= my_string_limit_words($excerpt,$excerpt_count); $output .= '</p>'; } if($more_text_single!=""){ $output .= '<a href="'.get_permalink($post->ID).'" class="btn btn-primary" title="'.get_the_title($post->ID).'">'; $output .= $more_text_single; $output .= '</a>'; } $output .= '</div>'; $output .= '</li>'; } $output .= '</ul>'; $output .= '</div></div>'; $output .= '<script> jQuery("#carousel-'. $type .'").elastislide({ imageW : '.$thumb_width.', minItems : '.$min_items.', speed : 600, easing : "easeOutQuart", margin : '.$spacer.', border : 0, onClick : function() {} });'; $output .= '</script>'; $output .= '</div>'; return $output; }
function shortcode_carousel($atts, $content = null) { wp_enqueue_script('elastislide', CHERRY_PLUGIN_URL . 'includes/assets/js/jquery.elastislide.js', array('jquery'), '1', true); wp_enqueue_script('easing', CHERRY_PLUGIN_URL . 'includes/assets/js/jquery.easing.1.3.js', array('jquery'), '1.3', true); extract(shortcode_atts(array('title' => '', 'num' => '8', 'type' => '', 'thumb' => 'true', 'thumb_width' => '220', 'thumb_height' => '180', 'more_text_single' => __('Read more', CHERRY_PLUGIN_DOMAIN), 'category' => '', 'custom_category' => '', 'excerpt_count' => '12', 'date' => '', 'author' => '', 'min_items' => '3', 'spacer' => '18', 'custom_class' => ''), $atts)); $template_url = get_stylesheet_directory_uri(); // check what type of post user selected switch ($type) { case 'blog': $type_post = 'post'; break; case 'portfolio': $type_post = 'portfolio'; break; case 'testimonial': $type_post = 'testi'; break; } $output = '<div class="carousel-wrap ' . $custom_class . '">'; if ($title != '') { $output .= '<h2>' . $title . '</h2>'; } $output .= '<div id="carousel-' . $type . '" class="es-carousel-wrapper">'; $output .= '<div class="es-carousel">'; $output .= '<ul class="es-carousel_list unstyled">'; global $post; global $my_string_limit_words; // WPML filter $suppress_filters = get_option('suppress_filters'); $args = array('post_type' => $type_post, 'category_name' => $category, $type_post . '_category' => $custom_category, 'numberposts' => $num, 'orderby' => 'post_date', 'order' => 'DESC', 'suppress_filters' => $suppress_filters); $latest = get_posts($args); $i = 0; foreach ($latest as $key => $post) { // Unset not translated posts if (function_exists('wpml_get_language_information')) { global $sitepress; $check = wpml_get_language_information($post->ID); $language_code = substr($check['locale'], 0, 2); if ($language_code != $sitepress->get_current_language()) { unset($latest[$key]); } // Post ID is different in a second language Solution if (function_exists('icl_object_id')) { $post = get_post(icl_object_id($post->ID, $type_post, true)); } } setup_postdata($post); $excerpt = get_the_excerpt(); $format = get_post_format(); $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); $url = $attachment_url['0']; $image = aq_resize($url, $thumb_width, $thumb_height, true); $link_format_url = get_post_meta(get_the_ID(), 'tz_link_url', true); $output .= '<li class="es-carousel_li ' . $format . '">'; if ($thumb == 'true') { if (has_post_thumbnail($post->ID) && $format == 'image') { $output .= '<figure class="featured-thumbnail">'; $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />'; $output .= '</a></figure>'; } elseif ($format != 'video' && $format != 'audio') { $thumbid = 0; $thumbid = get_post_thumbnail_id($post->ID); $images = get_children(array('orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => -1)); if ($images) { $k = 0; //looping through the images foreach ($images as $attachment_id => $attachment) { //if( $attachment->ID == $thumbid ) continue; $image_attributes = wp_get_attachment_image_src($attachment_id, 'full'); // returns an array $img = aq_resize($image_attributes[0], $thumb_width, $thumb_height, true); //resize & crop img $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); $image_title = $attachment->post_title; if ($k == 0) { $output .= '<figure class="featured-thumbnail">'; $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= '<img src="' . $img . '" alt="' . get_the_title($post->ID) . '" />'; } else { $output .= '<figure class="featured-thumbnail" style="display:none;">'; $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= '<img src="' . $img . '" alt="' . get_the_title($post->ID) . '" />'; } $output .= '</a></figure>'; $k++; } } elseif (has_post_thumbnail($post->ID)) { $output .= '<figure class="featured-thumbnail">'; $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />'; $output .= '</a></figure>'; } /*else { // empty_featured_thumb.gif - for post without featured thumbnail $output .= '<figure class="featured-thumbnail">'; $output .= '<a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$template_url.'/images/empty_thumb.gif" alt="'.get_the_title($post->ID).'" />'; $output .= '</a></figure>'; }*/ } else { if (has_post_thumbnail($post->ID)) { // for Video and Audio post format - no lightbox $output .= '<figure class="featured-thumbnail"><a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />'; $output .= '</a></figure>'; } /*else { // empty_featured_thumb.gif - for post without featured thumbnail $output .= '<figure class="featured-thumbnail">'; $output .= '<a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$template_url.'/images/empty_thumb.gif" alt="'.get_the_title($post->ID).'" />'; $output .= '</a></figure>'; }*/ } } $output .= '<div class="desc">'; if ($date == "yes") { $output .= '<time datetime="' . get_the_time('Y-m-d\\TH:i:s', $post->ID) . '">' . get_the_date() . '</time>'; } if ($author == "yes") { $output .= '<em class="author">, ' . __('by ', CHERRY_PLUGIN_DOMAIN) . ' <a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_the_author_meta('display_name') . '</a></em>'; } //Link format if ($format == "link") { $output .= '<h5><a href="' . $link_format_url . '" title="' . get_the_title($post->ID) . '">'; $output .= get_the_title($post->ID); $output .= '</a></h5>'; //Other formats } else { $output .= '<h5><a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= get_the_title($post->ID); $output .= '</a></h5>'; } if ($excerpt_count >= 1) { $output .= '<p class="excerpt">'; $output .= my_string_limit_words($excerpt, $excerpt_count); $output .= '</p>'; } if ($more_text_single != "") { $output .= '<a href="' . get_permalink($post->ID) . '" class="btn btn-primary" title="' . get_the_title($post->ID) . '">'; $output .= $more_text_single; $output .= '</a>'; } $output .= '</div>'; $output .= '</li>'; } wp_reset_postdata(); // restore the global $post variable $output .= '</ul>'; $output .= '</div></div>'; $output .= '<script> jQuery(document).ready(function(){ jQuery("#carousel-' . $type . '").elastislide({ imageW : ' . $thumb_width . ', minItems : ' . $min_items . ', speed : 600, easing : "easeOutQuart", margin : ' . $spacer . ', border : 0, onClick : function() {} }); })'; $output .= '</script>'; $output .= '</div>'; return $output; }
$title = the_title('', '', FALSE); echo substr($title, 0, 40); ?> </a></h3> <?php } ?> <?php if ($folio_excerpt == "yes") { ?> <p class="excerpt"><?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt, $folio_excerpt_count); ?> </p> <?php } ?> <?php if ($folio_btn == "yes") { $button_text = of_get_option('folio_button_text') ? of_get_option('folio_button_text') : theme_locals("read_more"); ?> <p><a href="<?php the_permalink(); ?>
/** * Displays custom posts widget on blog. */ function widget($args, $instance) { global $post; $post_old = $post; // Save the post object. extract($args); $limit = apply_filters('widget_title', $instance['excerpt_length']); $valid_sort_orders = array('date', 'title', 'comment_count', 'rand'); if (in_array($instance['sort_by'], $valid_sort_orders)) { $sort_by = $instance['sort_by']; $sort_order = (bool) $instance['asc_sort_order'] ? 'ASC' : 'DESC'; } else { // by default, display latest first $sort_by = 'date'; $sort_order = 'DESC'; } // Get array of post info. $cat_posts = new WP_Query("showposts=" . $instance["num"] . "&post_type=" . $instance['posttype'] . "&orderby=" . $sort_by . "&order=" . $sort_order); echo $before_widget; // Widget title // If title exist. if ($instance["title"]) { echo $before_title; echo $instance["title"]; echo $after_title; } // Posts list if ($instance['container_class'] == "") { echo "<ul class='post_list'>\n"; } else { echo "<ul class='post_list " . $instance['container_class'] . "'>\n"; } $limittext = $limit; $posts_counter = 0; while ($cat_posts->have_posts()) { $cat_posts->the_post(); $posts_counter++; ?> <?php if ($instance['posttype'] == "testi") { $custom = get_post_custom($post->ID); $testiname = $custom["testimonial-name"][0]; $testiurl = $custom["testimonial-url"][0]; } ?> <li class="cat_post_item-<?php echo $posts_counter; ?> clearfix"> <?php if ($instance["thumb"]) { ?> <?php if ($instance['thumb_as_link']) { ?> <a href="<?php the_permalink(); ?> "> <?php } ?> <?php if ($instance['thumb_w'] !== "" || $instance['thumb_h'] !== "") { ?> <?php the_post_thumbnail(array($instance['thumb_w'], $instance['thumb_h'])); ?> <?php } else { ?> <?php the_post_thumbnail(); ?> <?php } ?> <?php if ($instance['thumb_as_link']) { ?> </a> <?php } ?> <?php } ?> <?php if ($instance['show_title']) { ?> <?php echo $instance["before_post_title"]; ?> <a class="post-title" href="<?php the_permalink(); ?> " rel="bookmark" title="<?php the_title_attribute(); ?> "><?php if ($instance['show_title_date']) { ?> [<?php the_time('m-d-Y'); ?> ]<?php } else { the_title(); } ?> </a><?php echo $instance["after_post_title"]; ?> <?php } ?> <div> <?php if ($instance['comment_num']) { ?> <div class="fright">(<?php comments_number(); ?> )</div> <?php } ?> <?php if ($instance['date']) { ?> <div class="post_meta">Written by <?php the_author_posts_link(); ?> <time datetime="<?php the_time('Y-m-d\\TH:i'); ?> "><?php the_time('l, j F Y'); ?> <?php the_time(); ?> </time></div> <?php } ?> </div> <div class="post_content"> <?php if ($instance['excerpt']) { ?> <?php if ($limittext == "" || $limittext == 0) { ?> <?php if ($instance['excerpt_as_link']) { ?> <a href="<?php the_permalink(); ?> "> <?php } ?> <?php the_excerpt(); ?> <?php if ($instance['excerpt_as_link']) { ?> </a> <?php } ?> <?php } else { ?> <?php if ($instance['excerpt_as_link']) { ?> <a href="<?php the_permalink(); ?> "> <?php } ?> <?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt, $limittext); ?> <?php if ($instance['excerpt_as_link']) { ?> </a> <?php } ?> <?php } ?> <?php } ?> </div> <?php if ($instance['posttype'] == "testi") { ?> <div class="name-testi"><span class="user"><?php echo $testiname; ?> </span>, <a href="http://<?php echo $testiurl; ?> "><?php echo $testiurl; ?> </a></div> <?php } ?> <?php if ($instance['more_link']) { ?> <a href="<?php the_permalink(); ?> " class="<?php if ($instance['more_link_class'] != "") { echo $instance['more_link_class']; } else { ?> link<?php } ?> "><?php if ($instance['more_link_text'] == "") { ?> Read more<?php } else { echo $instance['more_link_text']; } ?> </a> <?php } ?> </li> <?php } ?> <?php echo "</ul>\n"; ?> <?php if ($instance['global_link']) { ?> <a href="<?php echo $instance['global_link_href']; ?> " class="link_show_all"><?php if ($instance['global_link_text'] == "") { ?> View all<?php } else { echo $instance['global_link_text']; } ?> </a> <?php } ?> <?php echo $after_widget; $post = $post_old; // Restore the post object. }
" /></a></span> <?php } ?> <div class="folio-desc"> <h3><a href="<?php the_permalink(); ?> "><?php $title = the_title('', '', FALSE); echo substr($title, 0, 40); ?> </a></h3> <?php $content = get_the_content(); echo my_string_limit_words($content, 23); ?> </div> </li> <?php $i++; $addclass = ""; } } ?> </ul> <div class="clear"></div> </div>
function shortcode_recenttesti($atts, $content = null) { extract(shortcode_atts(array('num' => '5', 'thumb' => 'true', 'excerpt_count' => '30', 'custom_class' => ''), $atts)); // WPML filter $suppress_filters = get_option('suppress_filters'); $args = array('post_type' => 'testi', 'numberposts' => $num, 'orderby' => 'post_date', 'suppress_filters' => $suppress_filters); $testi = get_posts($args); $output = '<div class="testimonials ' . $custom_class . '">'; global $post; global $my_string_limit_words; foreach ($testi as $k => $post) { // Unset not translated posts if (function_exists('wpml_get_language_information')) { global $sitepress; $check = wpml_get_language_information($post->ID); $language_code = substr($check['locale'], 0, 2); if ($language_code != $sitepress->get_current_language()) { unset($testi[$k]); } // Post ID is different in a second language Solution if (function_exists('icl_object_id')) { $post = get_post(icl_object_id($post->ID, 'testi', true)); } } setup_postdata($post); $excerpt = get_the_excerpt(); $testiname = get_post_meta(get_the_ID(), 'my_testi_caption', true); $testiurl = get_post_meta(get_the_ID(), 'my_testi_url', true); $testiinfo = get_post_meta(get_the_ID(), 'my_testi_info', true); $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); $url = $attachment_url['0']; $image = aq_resize($url, 280, 240, true); $output .= '<div class="testi-item">'; $output .= '<div class="testi-meta">'; if (isset($testiname)) { $output .= '<div class="user">'; $output .= $testiname; $output .= '</div>'; } if (isset($testiinfo)) { $output .= '<div class="info">('; $output .= $testiinfo; $output .= ')</div>'; } $output .= '</div>'; $output .= '<blockquote class="testi-item_blockquote">'; if ($thumb == 'true') { if (has_post_thumbnail($post->ID)) { $output .= '<figure class="featured-thumbnail">'; $output .= '<img src="' . $image . '" alt="" />'; $output .= '</figure>'; } } $output .= '<a href="' . get_permalink($post->ID) . '">'; $output .= my_string_limit_words($excerpt, $excerpt_count); $output .= '</a><span class="close_quote"></span><div class="clear"></div>'; $output .= '</blockquote>'; $output .= '</div>'; } wp_reset_postdata(); // restore the global $post variable $output .= '</div>'; return $output; }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $post_type = $instance['post_type']; $categories = $instance['categories']; $count = $instance['count']; $thumb_width = $instance['thumb_width']; $thumb_height = $instance['thumb_height']; $show_title = $instance['show_title'] == 'true' ? true : false; $show_date = $instance['show_date'] == 'true' ? true : false; $show_author = $instance['show_author'] == 'true' ? true : false; $show_comments = $instance['show_comments'] == 'true' ? true : false; $show_excerpt = $instance['show_excerpt'] == 'true' ? true : false; $excerpt_count = $instance['excerpt_count']; $more_text_single = apply_filters('cherry_text_translate', $instance['more_text_single'], $instance['title'] . ' more_text_single'); $control_nav = $instance['control_nav']; $direction_nav = $instance['direction_nav']; $speed = $instance['speed']; $speed = (int) $speed * 1000; $random = uniqid(); $get_category_type = $post_type == 'post' ? 'category' : $post_type . '_category'; $categories_ids = array(); foreach (explode(',', str_replace(', ', ',', $categories)) as $category) { $get_cat_id = get_term_by('name', $category, $get_category_type); if ($get_cat_id) { $categories_ids[] = $get_cat_id->term_id; } } $get_query_tax = $categories_ids ? 'tax_query' : ''; if (!$count) { $count = -1; } $args = array('post_status' => 'publish', 'posts_per_page' => $count, 'ignore_sticky_posts' => 1, 'post_type' => $post_type, "{$get_query_tax}" => array(array('taxonomy' => $get_category_type, 'field' => 'id', 'terms' => $categories_ids))); $post_cycle = new WP_Query($args); if ($post_cycle->have_posts()) { if ($title) { ?> <div style = "text-align: center; background: url('http://dulichbinhhung.com/wp-content/uploads/2015/pattern2.png') repeat-x; background-position: 0 50%; margin-bottom: 20px;"> <span style="font-size: 30px; color: #212121; background: #fff; padding: 0 20px; font-family: tahoma;"> <?php echo $title; ?> </span> </div> <?php } ?> <script type="text/javascript"> jQuery(window).load(function() { jQuery('#flexslider_<?php echo $random; ?> ').flexslider({ animation: "slide", smoothHeight: true, slideshow: true, slideshowSpeed: <?php echo $speed; ?> , controlNav: <?php echo $control_nav; ?> , directionNav: <?php echo $direction_nav; ?> , prevText: '', nextText: '' }); }); </script> <div id="flexslider_<?php echo $random; ?> " class="flexslider widget-flexslider"> <ul class="slides unstyled"> <?php while ($post_cycle->have_posts()) { $post_cycle->the_post(); if (has_post_thumbnail()) { $post_id = $post_cycle->post->ID; $post_title = esc_html(get_the_title($post_id)); $post_title_attr = esc_attr(strip_tags(get_the_title($post_id))); $format = get_post_format($post_id); $format = empty($format) ? 'format-standart' : 'format-' . $format; $thumb = get_post_thumbnail_id(); $img_url = wp_get_attachment_url($thumb, 'full'); $image = aq_resize($img_url, $thumb_width, $thumb_height, true); $post_permalink = $format == 'format-link' ? esc_url(get_post_meta($post_id, 'tz_link_url', true)) : get_permalink($post_id); if (has_excerpt($post_id)) { $excerpt = get_the_excerpt(); } else { $excerpt = get_the_content(); } ?> <li class="slide <?php echo $format; ?> clearfix"> <figure class="thumbnail" style="margin: 0px; display:none;"> <a href="<?php echo $post_permalink; ?> " title="<?php echo $post_title; ?> "> <img src="<?php echo $image; ?> " alt="<?php echo $post_title; ?> " /> </a> </figure> <div class="desc" style="text-align:center;"> <?php // post date if ($show_date) { ?> <time datetime="<?php echo get_the_time('Y-m-d\\TH:i:s', $post_id); ?> "><?php echo get_the_date(); ?> </time> <?php } // post author if ($show_author) { ?> <em class="author"> <span><?php _e('by', CHERRY_PLUGIN_DOMAIN); ?> </span> <a href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?> "><?php echo get_the_author_meta('display_name'); ?> </a> </em> <?php } // post title if ($show_title) { ?> <h5> <a href ="<?php echo $post_permalink; ?> " title="<?php echo $post_title_attr; ?> " style="color:#009bd9; font-size:20px;"><?php echo $post_title; ?> </a> </h5> <?php } // post excerpt if ($show_excerpt) { if ($excerpt_count > 0) { ?> <div style="width: 70%; margin-left:auto; margin-right:auto;"> <p class="excerpt" style = "text-align:justify;"> <?php echo my_string_limit_words($excerpt, $excerpt_count); ?> </p> </div> <?php } } // post comment count if ($show_comments) { $comment_count = $post_cycle->post->comment_count; if ($comment_count > 1) { $comment_count = $comment_count . ' <span>' . __('Comments', CHERRY_PLUGIN_DOMAIN) . '</span>'; } else { $comment_count = $comment_count . ' <span>' . __('Comment', CHERRY_PLUGIN_DOMAIN) . '</span>'; } echo '<a href="' . $post_permalink . '#comments" class="comments_link" style="text-align:center; font-size:16px;">' . $comment_count . '</a>'; } ?> </div> <?php // post more button $more_text_single = esc_html(wp_kses_data($more_text_single)); if ($more_text_single != '') { ?> <a href="<?php echo get_permalink($post_id); ?> " title="<?php echo $post_title_attr; ?> " class="btn btn-primary"><?php _e($more_text_single, CHERRY_PLUGIN_DOMAIN); ?> </a> <?php } ?> </li><!-- .slide --> <?php } } ?> </ul><!-- .slides --> </div><!-- .flexslider --> <?php echo $after_widget; } wp_reset_postdata(); }
function mini_posts_list_shortcode($atts, $content = null, $shortcodename = '') { extract(shortcode_atts(array('type' => 'post', 'numb' => '3', 'thumbs' => '', 'thumb_width' => '', 'thumb_height' => '', 'meta' => '', 'order_by' => '', 'order' => '', 'excerpt_count' => '0', 'custom_class' => ''), $atts)); $template_url = get_template_directory_uri(); // check what order by method user selected switch ($order_by) { case 'date': $order_by = 'post_date'; break; case 'title': $order_by = 'title'; break; case 'popular': $order_by = 'comment_count'; break; case 'random': $order_by = 'rand'; break; } // check what order method user selected (DESC or ASC) switch ($order) { case 'DESC': $order = 'DESC'; break; case 'ASC': $order = 'ASC'; break; } // thumbnail size $thumb_x = 0; $thumb_y = 0; if ($thumb_width != '' && $thumb_height != '') { $thumbs = 'custom_thumb'; $thumb_x = $thumb_width; $thumb_y = $thumb_height; } else { switch ($thumbs) { case 'small': $thumb_x = 110; $thumb_y = 110; break; case 'smaller': $thumb_x = 90; $thumb_y = 90; break; case 'smallest': $thumb_x = 60; $thumb_y = 60; break; } } global $post; global $my_string_limit_words; // WPML filter $suppress_filters = get_option('suppress_filters'); $args = array('post_type' => $type, 'numberposts' => $numb, 'orderby' => $order_by, 'order' => $order, 'suppress_filters' => $suppress_filters); $posts = get_posts($args); $i = 0; $output = '<ul class="mini-posts-list ' . $custom_class . '">'; foreach ($posts as $key => $post) { //Check if WPML is activated if (defined('ICL_SITEPRESS_VERSION')) { global $sitepress; $post_lang = $sitepress->get_language_for_element($post->ID, 'post_' . $type); $curr_lang = $sitepress->get_current_language(); // Unset not translated posts if ($post_lang != $curr_lang) { unset($posts[$key]); } // Post ID is different in a second language Solution if (function_exists('icl_object_id')) { $post = get_post(icl_object_id($post->ID, $type, true)); } } setup_postdata($post); $excerpt = get_the_excerpt(); $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); $url = $attachment_url['0']; $image = aq_resize($url, $thumb_x, $thumb_y, true); $mediaType = get_post_meta($post->ID, 'tz_portfolio_type', true); $format = get_post_format(); //$output .= '<div class="row-fluid">'; $output .= '<li class="mini-post-holder clearfix list-item-' . $i . '">'; //post thumbnail if ($thumbs != 'none') { if (has_post_thumbnail($post->ID) && ($format == 'image' || $mediaType == 'Image')) { $output .= '<figure class="a featured-thumbnail thumbnail ' . $thumbs . '">'; $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />'; $output .= '</a></figure>'; } elseif ($mediaType != 'Video' && $mediaType != 'Audio') { $thumbid = 0; $thumbid = get_post_thumbnail_id($post->ID); $images = get_children(array('orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => -1)); if ($images) { $k = 0; //looping through the images foreach ($images as $attachment_id => $attachment) { //$prettyType = "prettyPhoto[gallery".$i."]"; //if( $attachment->ID == $thumbid ) continue; $image_attributes = wp_get_attachment_image_src($attachment_id, 'full'); // returns an array $img = aq_resize($image_attributes[0], $thumb_x, $thumb_y, true); //resize & crop img $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); $image_title = $attachment->post_title; if ($k == 0) { if (has_post_thumbnail($post->ID)) { $output .= '<figure class="featured-thumbnail thumbnail">'; $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />'; } else { $output .= '<figure class="featured-thumbnail thumbnail ' . $thumbs . '">'; $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= '<img src="' . $img . '" alt="' . get_the_title($post->ID) . '" />'; } } $output .= '</a></figure>'; $k++; } } elseif (has_post_thumbnail($post->ID)) { //$prettyType = 'prettyPhoto'; $output .= '<figure class="featured-thumbnail thumbnail ' . $thumbs . '">'; $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />'; $output .= '</a></figure>'; } else { // empty_featured_thumb.gif - for post without featured thumbnail $output .= '<figure class="featured-thumbnail thumbnail ' . $thumbs . '">'; $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= '<img src="' . $template_url . '/images/empty_thumb.gif" alt="' . get_the_title($post->ID) . '" />'; $output .= '</a></figure>'; } } else { // for Video and Audio post format - no lightbox $output .= '<figure class="featured-thumbnail thumbnail ' . $thumbs . '"><a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />'; $output .= '</a></figure>'; } } //mini post content $output .= '<div class="mini-post-content">'; $output .= '<h4><a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= get_the_title($post->ID); $output .= '</a></h4>'; if ($meta == 'yes') { // mini post meta $output .= '<div class="mini-post-meta">'; $output .= '<time datetime="' . get_the_time('Y-m-d\\TH:i:s', $post->ID) . '"> <span>' . get_the_date() . '</span></time>'; $output .= '</div>'; } $output .= cherry_get_post_networks(array('post_id' => $post->ID, 'display_title' => false, 'output_type' => 'return')); if ($excerpt_count >= 1) { $output .= '<div class="excerpt">'; $output .= my_string_limit_words($excerpt, $excerpt_count); $output .= '</div>'; } $output .= '</div>'; $output .= '</li>'; $i++; } // end foreach wp_reset_postdata(); // restore the global $post variable $output .= '</ul><!-- .mini-posts-list (end) -->'; $output = apply_filters('cherry_plugin_shortcode_output', $output, $atts, $shortcodename); return $output; }
/** @see WP_Widget::widget */ function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $category = apply_filters('widget_category', $instance['category']); $linktext = apply_filters('widget_linktext', $instance['linktext']); $linkurl = apply_filters('widget_linkurl', $instance['linkurl']); ?> <?php echo $before_widget; ?> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <?php if (have_posts()) { ?> <ul class="latestpost"> <?php $querycat = $category; ?> <?php query_posts("showposts=3&cat=" . $querycat); ?> <?php while (have_posts()) { the_post(); ?> <li> <a href="<?php the_permalink(); ?> " rel="bookmark" title="<?php _e('Permanent Link to', 'my_framework'); ?> <?php the_title_attribute(); ?> "> <span class="smalltext"><?php the_time('F j, Y'); ?> </span> <h4><?php the_title(); ?> </h4> <?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt, 10); ?> <small class="more"><?php _e('more', 'my_framework'); ?> »</small></a> </li> <?php } ?> </ul> <?php } ?> <!-- Print a link to this category --> <?php if ($linkurl != "") { ?> <span class="text-styled"><a href="<?php echo $linkurl; ?> "><?php echo $linktext; ?> </a></span> <?php } ?> <?php wp_reset_query(); ?> <?php echo $after_widget; ?> <?php }
/** @see WP_Widget::widget */ function widget($args, $instance) { extract($args); $limit = apply_filters('widget_limit', $instance['limit']); $count = apply_filters('widget_count', $instance['count']); $linktext = apply_filters('widget_linktext', $instance['linktext']); ?> <?php echo $before_widget; ?> <div class="banners_cycle" id="banners-cycle"> <?php $limittext = $limit; ?> <?php global $more; $more = 0; $counter = 1; ?> <?php query_posts("posts_per_page=" . $count . "&post_type=banners"); ?> <?php while (have_posts()) { the_post(); ?> <?php $custom = get_post_custom($post->ID); $bannertitle = $custom["banner-title"][0]; $buttonurl = $custom["button-url"][0]; ?> <div class="banners_item banners_item_<?php echo $counter; ?> "> <span class="banner-title"><div class="title-text"><?php echo $bannertitle; ?> </div></span> <div class="description"> <div class="inside"> <h1><?php the_title(); ?> </h1> <p><?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt, $limit); ?> </p> <?php if ($buttonurl == "") { ?> <a href="<?php the_permalink(); ?> " class="banner-button"><?php if ($linktext == "") { echo 'Read more'; } else { echo $linktext; } ?> </a> <?php } else { ?> <a href="<?php echo $buttonurl; ?> " class="banner-button"><?php if ($linktext == "") { echo 'Read more'; } else { echo $linktext; } ?> </a> <?php } ?> </div> </div> </div> <?php $counter++; } ?> <?php wp_reset_query(); ?> </div> <?php echo $after_widget; ?> <?php }
$image_title = $attachment->post_title; ?> <a href="<?php echo $image_attributes[0]; ?>" title="<?php the_title(); ?>" rel="<?php echo $prettyType; ?>" style="display:none;"></a> <?php } } } else { ?> <figure class="thumbnail thumbnail__portfolio"> <a class="image-wrap" href="<?php the_permalink() ?>" title="<?php echo theme_locals("permanent_link_to"); ?> <?php the_title_attribute(); ?>" ><img src="<?php echo $image ?>" alt="<?php the_title(); ?>" /></a> </figure> <?php } ?> <!-- Caption --> <div class="caption caption__portfolio"> <?php if($folio_title == "yes"){ ?> <h3><a href="<?php the_permalink(); ?>"><?php $title = the_title('','',FALSE); echo substr($title, 0, 40); ?></a></h3> <?php } ?> <?php if($folio_excerpt == "yes"){ ?> <p class="excerpt"><?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt,$folio_excerpt_count);?></p> <?php } ?> <?php if($folio_btn == "yes"){ ?> <p><a href="<?php the_permalink() ?>" class="btn btn-primary"><?php echo theme_locals("read_more"); ?></a></p> <?php } ?> </div><!-- /Caption --> </div> </li> <?php $i++; endwhile; ?>
function postExcerptBuilder($postID, $excerpt_count) { if ($excerpt_count != 0) { $output = ''; if (has_excerpt($postID)) { $excerpt = wp_strip_all_tags(get_the_excerpt()); } else { $excerpt = wp_strip_all_tags(strip_shortcodes(get_the_content())); } if (!empty($excerpt[0])) { $output .= $excerpt_count == -1 ? '<p class="excerpt">' . $excerpt . '</p>' : '<p class="excerpt">' . my_string_limit_words($excerpt, $excerpt_count) . '</p>'; } return $output; } }
/** * Displays custom posts widget on blog. */ function widget($args, $instance) { global $post; $post_old = $post; // Save the post object. extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance); if (isset($instance['excerpt_length'])) { $limit = apply_filters('widget_title', $instance['excerpt_length']); } else { $limit = 0; } $more_link_text = apply_filters('cherry_text_translate', $instance['more_link_text'], $instance['title'] . ' more_link_text'); $global_link_text = apply_filters('cherry_text_translate', $instance['global_link_text'], $instance['title'] . ' global_link_text'); $valid_sort_orders = array('date', 'title', 'comment_count', 'rand'); if (in_array($instance['sort_by'], $valid_sort_orders)) { $sort_by = $instance['sort_by']; $sort_order = (bool) $instance['asc_sort_order'] ? 'ASC' : 'DESC'; } else { // by default, display latest first $sort_by = 'date'; $sort_order = 'DESC'; } // Get array of post info. $args = array('showposts' => $instance["num"], 'post_type' => $instance['posttype'], 'orderby' => $sort_by, 'order' => $sort_order, 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-aside', 'post-format-gallery', 'post-format-link', 'post-format-image', 'post-format-quote', 'post-format-audio', 'post-format-video'), 'operator' => 'NOT IN'))); $cat_posts = new WP_Query($args); echo $before_widget; // Widget title // If title exist. if ($title) { echo $before_title; echo $title; echo $after_title; } // Posts list if ($instance['container_class'] == "") { echo "<ul class='post-list unstyled'>\n"; } else { echo "<ul class='post-list unstyled " . $instance['container_class'] . "'>\n"; } $limittext = $limit; $posts_counter = 0; while ($cat_posts->have_posts()) { $cat_posts->the_post(); $posts_counter++; if ($instance['posttype'] == "testi") { $testiname = get_post_meta($post->ID, 'my_testi_caption', true); $testiurl = esc_url(get_post_meta($post->ID, 'my_testi_url', true)); $testiemail = sanitize_email(get_post_meta($post->ID, 'my_testi_email', true)); } $thumb = get_post_thumbnail_id(); $img_url = wp_get_attachment_url($thumb, 'full'); //get img URL $image = aq_resize($img_url, $instance['thumb_w'], $instance['thumb_h'], true); //resize & crop img ?> <li class="cat_post_item-<?php echo $posts_counter; ?> clearfix"> <?php if (has_post_thumbnail()) { if ($instance["thumb"]) { ?> <figure class="featured-thumbnail thumbnail"> <?php if ($instance['thumb_as_link']) { ?> <a href="<?php the_permalink(); ?> "> <?php } if ($instance['thumb_w'] !== "" || $instance['thumb_h'] !== "") { $thumb_w = $instance['thumb_w']; $thumb_h = $instance['thumb_h']; ?> <img src="<?php echo $image; ?> " width="<?php echo $thumb_w; ?> " height="<?php echo $thumb_h; ?> " alt="<?php the_title(); ?> " /> <?php } else { the_post_thumbnail(); } if ($instance['thumb_as_link']) { ?> </a> <?php } ?> </figure> <?php } } if ($instance['date']) { ?> <time datetime="<?php the_time('Y-m-d\\TH:i'); ?> "><?php the_date('d/m/Y'); ?> </time> <?php } if ($instance['comment_num']) { ?> <span class="post-list_comment"><?php comments_number(); ?> </span> <?php } if ($instance['show_title']) { ?> <h4 class="post-list_h"><a class="post-title" href="<?php the_permalink(); ?> " rel="bookmark" title="<?php the_title_attribute(); ?> "><?php if ($instance['show_title_date']) { ?> [<?php echo get_the_date(); ?> ]<?php } else { the_title(); } ?> </a></h4> <?php } ?> <div class="excerpt"> <?php if ($instance['excerpt']) { ?> <?php if ($limittext == "" || $limittext == 0) { ?> <?php if ($instance['excerpt_as_link']) { ?> <a href="<?php the_permalink(); ?> "> <?php } ?> <?php the_excerpt(); ?> <?php if ($instance['excerpt_as_link']) { ?> </a> <?php } ?> <?php } else { ?> <?php if ($instance['excerpt_as_link']) { ?> <a href="<?php the_permalink(); ?> "> <?php } ?> <?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt, $limittext); ?> <?php if ($instance['excerpt_as_link']) { ?> </a> <?php } ?> <?php } ?> <?php } ?> </div> <?php if ($instance['posttype'] == "testi") { ?> <div class="name-testi"> <?php if (!empty($testiname)) { ?> <span class="user"><?php echo $testiname; ?> </span><?php echo ', '; ?> <?php } ?> <?php if (!empty($testiurl)) { ?> <a class="testi-url" href="<?php echo $testiurl; ?> " target="_blank"><?php echo $testiurl; ?> </a><br> <?php } ?> <?php if (!empty($testiemail) && is_email($testiemail)) { echo '<a class="testi-email" href="mailto:' . antispambot($testiemail, 1) . '">' . antispambot($testiemail) . ' </a>'; } ?> </div> <?php } ?> <?php if ($instance['more_link']) { ?> <a href="<?php the_permalink(); ?> " class="btn btn-primary <?php if ($instance['more_link_class'] != "") { echo $instance['more_link_class']; } else { ?> link<?php } ?> "><?php if ($instance['more_link_text'] == "") { _e('Read more', CHERRY_PLUGIN_DOMAIN); } else { echo $more_link_text; } ?> </a> <?php } ?> </li><!--//.post-list_li --> <?php } ?> <?php echo "</ul>\n"; ?> <?php if ($instance['global_link']) { ?> <a href="<?php echo $instance['global_link_href']; ?> " class="btn btn-primary link_show_all"><?php if ($instance['global_link_text'] == "") { _e('View all', CHERRY_PLUGIN_DOMAIN); } else { echo $global_link_text; } ?> </a> <?php } ?> <?php echo $after_widget; $post = $post_old; // Restore the post object. }
/** @see WP_Widget::widget */ function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $limit = apply_filters('widget_title', $instance['limit']); $category = apply_filters('widget_category', $instance['category']); $count = apply_filters('widget_count', $instance['count']); ?> <?php echo $before_widget; ?> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <?php if ($category == "testi") { ?> <ul class="testimonials"> <?php $limittext = $limit; ?> <?php global $more; $more = 0; ?> <?php query_posts("posts_per_page=" . $count . "&post_type=" . $category); ?> <?php while (have_posts()) { the_post(); ?> <?php $custom = get_post_custom($post->ID); $testiname = $custom["testimonial-name"][0]; $testiurl = $custom["testimonial-url"][0]; ?> <li class="testi_item"> <?php if ($limittext == "" || $limittext == 0) { ?> <blockquote class="quote"> <?php the_excerpt(); ?> </blockquote> <div class="name-testi"> <span class="user"><?php echo $testiname; ?> </span>, <a href="http://<?php echo $testiurl; ?> "><?php echo $testiurl; ?> </a> </div> <?php } else { ?> <blockquote class="quote"> <?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt, $limittext); ?> </blockquote> <div class="name-testi"> <span class="user"><?php echo $testiname; ?> </span>, <a href="http://<?php echo $testiurl; ?> "><?php echo $testiurl; ?> </a> </div> <?php } ?> </li> <?php } ?> <?php wp_reset_query(); ?> </ul> <!-- end of testimonials --> <?php } elseif ($category == "portfolio") { ?> <ul class="folio_cycle"> <?php $limittext = $limit; ?> <?php global $more; $more = 0; ?> <?php query_posts("posts_per_page=" . $count . "&post_type=" . $category . "&portfoliocat=" . $slug); ?> <?php while (have_posts()) { the_post(); ?> <li class="folio_item"> <?php if ($limittext == "" || $limittext == 0) { ?> <a href="<?php the_permalink(); ?> "><figure class="thumbnail"><?php the_post_thumbnail('small-post-thumbnail'); ?> </figure></a> <?php } else { ?> <a href="<?php the_permalink(); ?> "><figure class="thumbnail"><?php the_post_thumbnail('small-post-thumbnail'); ?> </figure></a> <?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt, $limittext); } ?> </li> <?php } ?> <?php wp_reset_query(); ?> </ul> <!-- end of portfolio_cycle --> <?php } else { ?> <ul class="post_cycle"> <?php $limittext = $limit; ?> <?php global $more; $more = 0; ?> <?php query_posts("posts_per_page=" . $count . "&post_type=" . $category . "&portfoliocat=" . $slug); ?> <?php while (have_posts()) { the_post(); ?> <li class="cycle_item"> <?php if ($limittext == "" || $limittext == 0) { ?> <a href="<?php the_permalink(); ?> "><figure class="featured-thumbnail small"><?php the_post_thumbnail('small-post-thumbnail'); ?> </figure></a> <h4><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h4> <?php the_excerpt(); ?> <?php } else { ?> <a href="<?php the_permalink(); ?> "><figure class="featured-thumbnail small"><?php the_post_thumbnail('small-post-thumbnail'); ?> </figure></a> <h4><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h4> <?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt, $limittext); } ?> </li> <?php } ?> <?php wp_reset_query(); ?> </ul> <!-- end of post_cycle --> <?php } ?> <?php echo $after_widget; ?> <?php }
function shortcode_carousel_owl($atts, $content = null, $shortcodename = '') { wp_enqueue_script('owl-carousel', CHERRY_PLUGIN_URL . 'lib/js/owl-carousel/owl.carousel.min.js', array('jquery'), '1.31', true); extract(shortcode_atts(array('title' => '', 'posts_count' => 10, 'post_type' => 'blog', 'post_status' => 'publish', 'visibility_items' => 5, 'thumb' => 'yes', 'thumb_width' => 220, 'thumb_height' => 180, 'more_text_single' => '', 'categories' => '', 'excerpt_count' => 15, 'date' => 'yes', 'author' => 'yes', 'comments' => 'no', 'auto_play' => 0, 'display_navs' => 'yes', 'display_pagination' => 'yes', 'custom_class' => ''), $args)); $random_ID = uniqid(); $posts_count = intval($posts_count); $thumb = $thumb == 'yes' ? true : false; $thumb_width = absint($thumb_width); $thumb_height = absint($thumb_height); $excerpt_count = absint($excerpt_count); $visibility_items = absint($visibility_items); $auto_play = absint($auto_play); $date = $date == 'yes' ? true : false; $author = $author == 'yes' ? true : false; $comments = $author == 'yes' ? true : false; $display_navs = $display_navs == 'yes' ? 'true' : 'false'; $display_pagination = $display_pagination == 'yes' ? 'true' : 'false'; $itemcounter = 0; switch (strtolower(str_replace(' ', '-', $post_type))) { case 'blog': $post_type = 'post'; break; case 'portfolio': $post_type = 'portfolio'; break; case 'testimonial': $post_type = 'testi'; break; case 'services': $post_type = 'services'; break; case 'our-team': $post_type = 'team'; break; } $get_category_type = $post_type == 'post' ? 'category' : $post_type . '_category'; $categories_ids = array(); foreach (explode(',', str_replace(', ', ',', $categories)) as $category) { $get_cat_id = get_term_by('name', $category, $get_category_type); if ($get_cat_id) { $categories_ids[] = $get_cat_id->term_id; } } $get_query_tax = $categories_ids ? 'tax_query' : ''; $suppress_filters = get_option('suppress_filters'); // WPML filter // WP_Query arguments $args = array('post_status' => $post_status, 'posts_per_page' => $posts_count, 'ignore_sticky_posts' => 1, 'post_type' => $post_type, 'suppress_filters' => $suppress_filters, "{$get_query_tax}" => array(array('taxonomy' => $get_category_type, 'field' => 'id', 'terms' => $categories_ids))); // The Query $carousel_query = new WP_Query($args); if ($carousel_query->have_posts()) { $output = '<div class="carousel-wrap ' . $custom_class . '">'; $output .= $title ? '<h2>' . $title . '</h2>' : ''; $output .= '<div id="owl-carousel-' . $random_ID . '" class="owl-carousel-' . $post_type . ' owl-carousel" data-items="' . $visibility_items . '" data-auto-play="' . $auto_play . '" data-nav="' . $display_navs . '" data-pagination="' . $display_pagination . '">'; while ($carousel_query->have_posts()) { $carousel_query->the_post(); $post_id = $carousel_query->post->ID; $post_title = esc_html(get_the_title($post_id)); $post_title_attr = esc_attr(strip_tags(get_the_title($post_id))); $format = get_post_format($post_id); $format = empty($format) ? 'format-standart' : 'format-' . $format; if (get_post_meta($post_id, 'tz_link_url', true)) { $post_permalink = $format == 'format-link' ? esc_url(get_post_meta($post_id, 'tz_link_url', true)) : get_permalink($post_id); } else { $post_permalink = get_permalink($post_id); } if (has_excerpt($post_id)) { $excerpt = wp_strip_all_tags(get_the_excerpt()); } else { $excerpt = wp_strip_all_tags(strip_shortcodes(get_the_content())); } $output .= '<div class="item ' . $format . ' item-list-' . $itemcounter . '">'; // post thumbnail if ($thumb) { if (has_post_thumbnail($post_id)) { $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'full'); $url = $attachment_url['0']; $image = aq_resize($url, $thumb_width, $thumb_height, true); $output .= '<figure>'; $output .= '<a href="' . $post_permalink . '" title="' . $post_title . '">'; $output .= '<img src="' . $image . '" alt="' . $post_title . '" />'; $output .= '</a>'; $output .= '</figure>'; } else { $attachments = get_children(array('orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post_id, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => 1)); if ($attachments) { foreach ($attachments as $attachment_id => $attachment) { $image_attributes = wp_get_attachment_image_src($attachment_id, 'full'); $img = aq_resize($image_attributes[0], $thumb_width, $thumb_height, true); $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); $output .= '<figure>'; $output .= '<a href="' . $post_permalink . '" title="' . $post_title . '">'; $output .= '<img src="' . $img . '" alt="' . $alt . '" />'; $output .= '</a>'; $output .= '</figure>'; } } } } $output .= '<div class="desc">'; // post date $output .= $date ? '<time datetime="' . get_the_time('Y-m-d\\TH:i:s', $post_id) . '">' . get_the_date() . '</time>' : ''; // post author $output .= $author ? '<em class="author"> <span>' . __('by ', CHERRY_PLUGIN_DOMAIN) . '</span> <a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_the_author_meta('display_name') . '</a> </em>' : ''; // post comment count if ($comments == 'yes') { $comment_count = $carousel_query->post->comment_count; if ($comment_count >= 1) { $comment_count = $comment_count . ' <span>' . __('Comments', CHERRY_PLUGIN_DOMAIN) . '</span>'; } else { $comment_count = $comment_count . ' <span>' . __('Comment', CHERRY_PLUGIN_DOMAIN) . '</span>'; } $output .= '<a href="' . $post_permalink . '#comments" class="comments_link">' . $comment_count . '</a>'; } // post title if (!empty($post_title[0])) { $output .= '<h5><a href="' . $post_permalink . '" title="' . $post_title_attr . '">'; $output .= $post_title; $output .= '</a></h5>'; } // post excerpt if (!empty($excerpt[0])) { $output .= $excerpt_count > 0 ? '<p class="excerpt">' . my_string_limit_words($excerpt, $excerpt_count) . '</p>' : ''; } // post more button $more_text_single = esc_html(wp_kses_data($more_text_single)); if ($more_text_single != '') { $output .= '<a href="' . get_permalink($post_id) . '" class="btn btn-primary" title="' . $post_title_attr . '">'; $output .= __($more_text_single, CHERRY_PLUGIN_DOMAIN); $output .= '</a>'; } $output .= '</div>'; $output .= '</div>'; $itemcounter++; } $output .= '</div></div>'; } // Restore original Post Data wp_reset_postdata(); $output = apply_filters('cherry_plugin_shortcode_output', $output, $atts, $shortcodename); return $output; }
function posts_list_shortcode($atts, $content = null) { extract(shortcode_atts(array('type' => 'post', 'thumbs' => '', 'thumb_width' => '', 'thumb_height' => '', 'post_content' => '', 'numb' => '5', 'order_by' => '', 'order' => '', 'link' => '', 'link_text' => theme_locals('read_more'), 'tags' => '', 'custom_class' => ''), $atts)); // check what order by method user selected switch ($order_by) { case 'date': $order_by = 'post_date'; break; case 'title': $order_by = 'title'; break; case 'popular': $order_by = 'comment_count'; break; case 'random': $order_by = 'rand'; break; } // check what order method user selected (DESC or ASC) switch ($order) { case 'DESC': $order = 'DESC'; break; case 'ASC': $order = 'ASC'; break; } global $post; global $my_string_limit_words; global $_wp_additional_image_sizes; // WPML filter $suppress_filters = get_option('suppress_filters'); $args = array('post_type' => $type, 'numberposts' => $numb, 'orderby' => $order_by, 'order' => $order, 'suppress_filters' => $suppress_filters); $posts = get_posts($args); $i = 0; // thumbnail size $thumb_x = 0; $thumb_y = 0; if ($thumbs == 'large') { $thumb_x = 620; $thumb_y = 300; } else { $thumb_x = $_wp_additional_image_sizes['post-thumbnail']['width']; $thumb_y = $_wp_additional_image_sizes['post-thumbnail']['height']; } // thumbnail class $thumbs_class = ''; if ($thumbs == 'large') { $thumbs_class = 'large'; } $output = '<div class="posts-list ' . $custom_class . '">'; foreach ($posts as $key => $post) { // Unset not translated posts if (function_exists('wpml_get_language_information')) { global $sitepress; $check = wpml_get_language_information($post->ID); $language_code = substr($check['locale'], 0, 2); if ($language_code != $sitepress->get_current_language()) { unset($posts[$key]); } // Post ID is different in a second language Solution if (function_exists('icl_object_id')) { $post = get_post(icl_object_id($post->ID, $type, true)); } } setup_postdata($post); $excerpt = get_the_excerpt(); $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); $url = $attachment_url['0']; if ($thumb_width != '' && $thumb_height != '') { $image = aq_resize($url, $thumb_width, $thumb_height, true); } else { $image = aq_resize($url, $thumb_x, $thumb_y, true); } $mediaType = get_post_meta($post->ID, 'tz_portfolio_type', true); $format = get_post_format(); $output .= '<div class="row-fluid">'; $output .= '<article class="span12 post__holder">'; //post header $output .= '<header class="post-header">'; $output .= '<h2 class="post-title"><a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= get_the_title($post->ID); $output .= '</a></h2>'; // post meta $output .= '<div class="post_meta">'; // post category $output .= '<span class="post_category">'; if ($type != '' && $type != 'post') { $terms = get_the_terms($post->ID, $type . '_category'); if ($terms && !is_wp_error($terms)) { $out = array(); $output .= theme_locals('posted_in') . ' '; foreach ($terms as $term) { $out[] = '<a href="' . get_term_link($term->slug, $type . '_category') . '">' . $term->name . '</a>'; } $output .= join(', ', $out); } } else { $categories = get_the_category(); if ($categories) { $out = array(); $output .= theme_locals('posted_in') . ' '; foreach ($categories as $category) { $out[] = '<a href="' . get_category_link($category->term_id) . '" title="' . $category->name . '">' . $category->cat_name . '</a> '; } $output .= join(', ', $out); } } $output .= '</span>'; // post date $output .= '<span class="post_date">'; $output .= '<time datetime="' . get_the_time('Y-m-d\\TH:i:s', $post->ID) . '">' . get_the_date() . '</time>'; $output .= '</span>'; // post author $output .= '<span class="post_author">'; $output .= theme_locals('by') . ' '; $output .= '<a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_the_author_meta('display_name') . '</a>'; $output .= '</span>'; // post comment count $num = 0; $post_id = $post->ID; $queried_post = get_post($post_id); $cc = $queried_post->comment_count; if ($cc == $num || $cc > 1) { $cc = $cc . ' ' . theme_locals('comments'); } else { $cc = $cc . ' ' . theme_locals('comment'); } $permalink = get_permalink($post_id); $output .= '<span class="post_comment">'; $output .= '<a href="' . $permalink . '" class="comments_link">' . $cc . '</a>'; $output .= '</span>'; $output .= '</div>'; $output .= cherry_get_post_networks(array('post_id' => $post_id, 'display_title' => false, 'output_type' => 'return')); $output .= '</header>'; //post thumbnail if (has_post_thumbnail($post->ID) && ($format == 'image' || $mediaType == 'Image')) { $output .= '<figure class="featured-thumbnail thumbnail ' . $thumbs_class . '">'; $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />'; $output .= '</a></figure>'; } elseif ($mediaType != 'Video' && $mediaType != 'Audio') { $thumbid = 0; $thumbid = get_post_thumbnail_id($post->ID); $images = get_children(array('orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => -1)); if ($images) { $k = 0; //looping through the images foreach ($images as $attachment_id => $attachment) { $image_attributes_t = wp_get_attachment_image_src($attachment_id); // returns an array (thumbnail size) $image_attributes = wp_get_attachment_image_src($attachment_id, 'full'); // returns an array (full size) if ($thumb_width != '' && $thumb_height != '') { $img = aq_resize($image_attributes[0], $thumb_width, $thumb_height, true); //resize & crop img } else { $img = aq_resize($url, $thumb_x, $thumb_y, true); } $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); $image_title = $attachment->post_title; if ($k == 0) { $output .= '<figure class="featured-thumbnail thumbnail ' . $thumbs_class . '">'; $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= '<img src="' . $img . '" alt="' . get_the_title($post->ID) . '" />'; } $output .= '</a></figure>'; break; } } elseif (has_post_thumbnail($post->ID)) { $output .= '<figure class="featured-thumbnail thumbnail ' . $thumbs_class . '">'; $output .= '<a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; if ($thumb_width != '' && $thumb_height != '') { $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />'; } else { if ($thumbs == 'normal') { $output .= get_the_post_thumbnail($post->ID); } else { $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />'; } } $output .= '</a></figure>'; } } else { // for Video and Audio post format - no lightbox $output .= '<figure class="featured-thumbnail thumbnail ' . $thumbs_class . '"><a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; if ($thumb_width != '' && $thumb_height != '') { $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />'; } else { if ($thumbs == 'normal') { $output .= get_the_post_thumbnail($post->ID); } else { $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />'; } } $output .= '</a></figure>'; } // post content if ($post_content != 'none' || $link == 'yes') { $output .= '<div class="post_content">'; switch ($post_content) { case 'excerpt': $output .= '<p class="excerpt">'; $output .= my_string_limit_words(get_the_excerpt(), 50); $output .= '</p>'; break; case 'content': $output .= '<div class="full-post-content">'; $output .= get_the_content(); $output .= '</div>'; break; case 'none': break; } if ($link == 'yes') { $output .= '<a href="' . get_permalink($post->ID) . '" class="btn btn-primary" title="' . get_the_title($post->ID) . '">'; $output .= $link_text; $output .= '</a>'; } $output .= '</div>'; } //post footer if ($tags == 'yes') { $posttags = get_the_tags(); if ($posttags) { $output .= '<footer class="post_footer">' . theme_locals('tags') . ": "; foreach ($posttags as $tag) { $output .= '<a href="' . get_tag_link($tag->term_id) . '" rel="tag">' . $tag->name . '</a> '; } $output .= '</footer>'; } } $output .= '</article>'; $output .= '</div><!-- .row-fluid (end) -->'; $i++; } // end foreach $output .= '</div><!-- .posts-list (end) -->'; return $output; }
/** @see WP_Widget::widget */ function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); ?> <?php echo $before_widget; ?> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <?php global $wpdb; ?> <ul class="popular-posts"> <?php $pop_posts = 5; $popularposts = "SELECT {$wpdb->posts}.ID, {$wpdb->posts}.post_title, COUNT({$wpdb->comments}.comment_post_ID) AS 'stammy' FROM {$wpdb->posts}, {$wpdb->comments} WHERE comment_approved = '1' AND {$wpdb->posts}.ID={$wpdb->comments}.comment_post_ID AND post_status = 'publish' AND comment_status = 'open' GROUP BY {$wpdb->comments}.comment_post_ID ORDER BY stammy DESC LIMIT " . $pop_posts; $posts = $wpdb->get_results($popularposts); if ($posts) { foreach ($posts as $post) { $post_title = stripslashes($post->post_title); $guid = get_permalink($post->ID); $thumb = get_post_meta($post->ID, '_thumbnail_id', false); $thumb = wp_get_attachment_image_src($thumb[0], 'small-post-thumbnail', false); $thumb = $thumb[0]; ?> <li> <?php if ($thumb) { ?> <figure class="post-thumb"> <img src="<?php echo $thumb; ?> " /> </figure> <?php } ?> <h5><a href="<?php echo $guid; ?> " title="<?php echo $post_title; ?> "><?php echo $post_title; ?> </a></h5> <?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt, 10); ?> </li> <?php } } ?> </ul> <?php echo $after_widget; ?> <?php }
function shortcode_post_cycle($atts, $content = null, $shortcodename = '') { extract(shortcode_atts(array('num' => '5', 'type' => 'post', 'meta' => '', 'effect' => 'slide', 'thumb' => 'true', 'thumb_width' => '200', 'thumb_height' => '180', 'more_text_single' => __('Read more', CHERRY_PLUGIN_DOMAIN), 'category' => '', 'custom_category' => '', 'excerpt_count' => '15', 'pagination' => 'true', 'navigation' => 'true', 'custom_class' => ''), $atts)); $type_post = $type; $slider_pagination = $pagination; $slider_navigation = $navigation; $random = gener_random(10); $i = 0; $rand = rand(); $count = 0; if (is_rtl()) { $is_rtl = 'true'; } else { $is_rtl = 'false'; } $output = '<script type="text/javascript"> jQuery(window).load(function() { jQuery("#flexslider_' . $random . '").flexslider({ animation: "' . $effect . '", smoothHeight : true, directionNav: ' . $slider_navigation . ', controlNav: ' . $slider_pagination . ', rtl: ' . $is_rtl . ' }); });'; $output .= '</script>'; $output .= '<div id="flexslider_' . $random . '" class="flexslider no-bg ' . $custom_class . '">'; $output .= '<ul class="slides">'; global $post; global $my_string_limit_words; // WPML filter $suppress_filters = get_option('suppress_filters'); $args = array('post_type' => $type_post, 'category_name' => $category, $type_post . '_category' => $custom_category, 'numberposts' => $num, 'orderby' => 'post_date', 'order' => 'DESC', 'suppress_filters' => $suppress_filters); $latest = get_posts($args); foreach ($latest as $key => $post) { //Check if WPML is activated if (defined('ICL_SITEPRESS_VERSION')) { global $sitepress; $post_lang = $sitepress->get_language_for_element($post->ID, 'post_' . $type_post); $curr_lang = $sitepress->get_current_language(); // Unset not translated posts if ($post_lang != $curr_lang) { unset($latest[$key]); } // Post ID is different in a second language Solution if (function_exists('icl_object_id')) { $post = get_post(icl_object_id($post->ID, $type_post, true)); } } setup_postdata($post); $excerpt = get_the_excerpt(); $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); $url = $attachment_url['0']; $image = aq_resize($url, $thumb_width, $thumb_height, true); $output .= '<li class="list-item-' . $count . '">'; if ($type == "testi") { $output .= '<figure class="quote-thumb"><i class="icon-quote-right "></i></figure>'; } if ($thumb == 'true') { if (has_post_thumbnail($post->ID)) { $output .= '<figure class="thumbnail featured-thumbnail"><a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />'; $output .= '</a></figure>'; } elseif ($type == "testi") { $output .= '<figure class="empty-thumb"><i class="icon-user"></i></figure>'; } } $output .= '<h5><a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= get_the_title($post->ID); $output .= '</a></h5>'; if ($meta == 'true') { $output .= '<span class="meta">'; $output .= '<span class="post-date">'; $output .= get_the_date(); $output .= '</span>'; $output .= '<span class="post-comments">' . __('Comments', CHERRY_PLUGIN_DOMAIN) . ": "; $output .= '<a href="' . get_comments_link($post->ID) . '">'; $output .= get_comments_number($post->ID); $output .= '</a>'; $output .= '</span>'; $output .= '</span>'; } //display post options if ($type == "testi") { $output .= '<div class="extra-wrap">'; } if ($excerpt_count >= 1) { $output .= '<p class="excerpt"><a href="' . get_comments_link($post->ID) . '">"'; $output .= my_string_limit_words($excerpt, $excerpt_count); $output .= '</a></p>'; } $output .= '<div class="post_options">'; switch ($type_post) { case "team": $teampos = get_post_meta($post->ID, 'my_team_pos', true); $team_email = sanitize_email(get_post_meta($post->ID, 'my_team_email', true)); $teaminfo = get_post_meta($post->ID, 'my_team_info', true); if (!empty($teampos)) { $output .= "<span class='page-desc'>" . $teampos . "</span><br>"; } if (!empty($team_email) && is_email($team_email)) { $output .= '<span class="team-email"><a href="mailto:' . antispambot($team_email, 1) . '">' . antispambot($team_email) . ' </a></span><br>'; } if (!empty($teaminfo)) { $output .= '<span class="team-content post-content team-info">' . esc_html($teaminfo) . '</span>'; } $output .= cherry_get_post_networks(array('post_id' => $post->ID, 'display_title' => false, 'output_type' => 'return')); break; case "testi": $testiname = get_post_meta($post->ID, 'my_testi_caption', true); $testiurl = esc_url(get_post_meta($post->ID, 'my_testi_url', true)); $testiinfo = get_post_meta($post->ID, 'my_testi_info', true); $testiemail = sanitize_email(get_post_meta($post->ID, 'my_testi_email', true)); if (!empty($testiname)) { $output .= '<span class="user">- ' . $testiname . '</span>'; } if (!empty($testiinfo)) { $output .= '<span class="info">, ' . $testiinfo . '</span><br>'; } if (!empty($testiurl)) { $output .= '<a class="testi-url" href="' . $testiurl . '" target="_blank">' . $testiurl . '</a><br>'; } if (!empty($testiemail) && is_email($testiemail)) { $output .= '<a class="testi-email" href="mailto:' . antispambot($testiemail, 1) . '">' . antispambot($testiemail) . ' </a>'; } break; case "portfolio": $portfolioClient = get_post_meta($post->ID, 'tz_portfolio_client', true) ? get_post_meta($post->ID, 'tz_portfolio_client', true) : ""; $portfolioDate = get_post_meta($post->ID, 'tz_portfolio_date', true) ? get_post_meta($post->ID, 'tz_portfolio_date', true) : ""; $portfolioInfo = get_post_meta($post->ID, 'tz_portfolio_info', true) ? get_post_meta($post->ID, 'tz_portfolio_info', true) : ""; $portfolioURL = get_post_meta($post->ID, 'tz_portfolio_url', true) ? get_post_meta($post->ID, 'tz_portfolio_url', true) : ""; $output .= "<strong class='portfolio-meta-key'>" . __('Client', CHERRY_PLUGIN_DOMAIN) . ": </strong><span> " . $portfolioClient . "</span><br>"; $output .= "<strong class='portfolio-meta-key'>" . __('Date', CHERRY_PLUGIN_DOMAIN) . ": </strong><span> " . $portfolioDate . "</span><br>"; $output .= "<strong class='portfolio-meta-key'>" . __('Info', CHERRY_PLUGIN_DOMAIN) . ": </strong><span> " . $portfolioInfo . "</span><br>"; $output .= "<a href='" . $portfolioURL . "'>" . __('Launch Project', CHERRY_PLUGIN_DOMAIN) . "</a><br>"; break; default: $output .= ""; } $output .= '</div>'; if ($type == "testi") { $output .= '</div>'; } if ($more_text_single != "") { $output .= '<a href="' . get_permalink($post->ID) . '" class="btn btn-primary" title="' . get_the_title($post->ID) . '">'; $output .= $more_text_single; $output .= '</a>'; } $output .= '</li>'; $count++; } wp_reset_postdata(); // restore the global $post variable $output .= '</ul>'; $output .= '</div>'; $output = apply_filters('cherry_plugin_shortcode_output', $output, $atts, $shortcodename); return $output; }
function shortcode_post_cycle($atts, $content = null) { extract(shortcode_atts(array( 'num' => '5', 'type' => '', 'meta' => '', 'effect' => 'slide', 'thumb' => 'true', 'thumb_width' => '200', 'thumb_height' => '180', 'more_text_single' => theme_locals('read_more'), 'category' => '', 'custom_category' => '', 'excerpt_count' => '15', 'pagination' => 'true', 'navigation' => 'true', 'custom_class' => '' ), $atts)); $type_post=$type; $slider_pagination=$pagination; $slider_navigation=$navigation; $random = gener_random(10); $output = '<script type="text/javascript"> $(window).load(function() { $("#flexslider_'.$random.'").flexslider({ animation: "'.$effect.'", smoothHeight : true, directionNav: '.$slider_navigation.', controlNav: '.$slider_pagination.' }); });'; $output .= '</script>'; $output .= '<div id="flexslider_'.$random.'" class="flexslider no-bg '.$custom_class.'">'; $output .= '<ul class="slides">'; global $post; global $my_string_limit_words; $args = array( 'post_type' => $type_post, 'category_name' => $category, $type_post . '_category' => $custom_category, 'numberposts' => $num, 'orderby' => 'post_date', 'order' => 'DESC' ); $latest = get_posts($args); foreach($latest as $post) { setup_postdata($post); $excerpt = get_the_excerpt(); $attachment_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); $url = $attachment_url['0']; $image = aq_resize($url, $thumb_width, $thumb_height, true); $output .= '<li>'; if ($thumb == 'true') { if ( has_post_thumbnail($post->ID) ){ $output .= '<figure class="thumbnail featured-thumbnail"><a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$image.'" alt="'.get_the_title($post->ID).'" />'; $output .= '</a></figure>'; } else { $thumbid = 0; $thumbid = get_post_thumbnail_id($post->ID); $images = get_children( array( 'orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => -1 ) ); if ( $images ) { $k = 0; //looping through the images foreach ( $images as $attachment_id => $attachment ) { $prettyType = "prettyPhoto[gallery".$i."]"; //if( $attachment->ID == $thumbid ) continue; $image_attributes = wp_get_attachment_image_src( $attachment_id, 'full' ); // returns an array $img = aq_resize( $image_attributes[0], $thumb_width, $thumb_height, true ); //resize & crop img $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); $image_title = $attachment->post_title; if ( $k == 0 ) { $output .= '<figure class="featured-thumbnail">'; $output .= '<a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$img.'" alt="'.get_the_title($post->ID).'" />'; $output .= '</a></figure>'; } break; $k++; } } } } $output .= '<h5><a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= get_the_title($post->ID); $output .= '</a></h5>'; $custom = get_post_custom($post->ID); if($meta == 'true'){ $output .= '<span class="meta">'; $output .= '<span class="post-date">'; $output .= get_the_time( get_option( 'date_format' ) ); $output .= '</span>'; $output .= '<span class="post-comments">'.theme_locals('comments').": "; $output .= '<a href="'.get_comments_link($post->ID).'">'; $output .= get_comments_number($post->ID); $output .= '</a>'; $output .= '</span>'; $output .= '</span>'; } //display post options $output .= '<div class="post_options">'; switch($type_post) { case "team": $teampos = ($custom["my_team_pos"][0])?$custom["my_team_pos"][0]:""; $teaminfo = ($custom["my_team_info"][0])?$custom["my_team_info"][0]:""; $output .= "<span class='page-desc'>".$teampos."</span><br><span class='team-content post-content'>".$teaminfo."</span>"; break; case "testi": $testiname = $custom["my_testi_caption"][0]?$custom["my_testi_caption"][0]:""; $testiurl = $custom["my_testi_url"][0]?$custom["my_testi_url"][0]:""; $testiinfo = $custom["my_testi_info"][0]?$custom["my_testi_info"][0]:""; $output .="<span class='user'>".$testiname."</span>, <span class='info'>".$testiinfo."</span><br><a href='".$testiurl."'>".$testiurl."</a>"; break; case "portfolio": $portfolioClient = $custom["tz_portfolio_client"][0]?$custom["tz_portfolio_client"][0]:""; $portfolioDate = $custom["tz_portfolio_date"][0]?$custom["tz_portfolio_date"][0]:""; $portfolioInfo = $custom["tz_portfolio_info"][0]?$custom["tz_portfolio_info"][0]:""; $portfolioURL = $custom["tz_portfolio_url"][0]?$custom["tz_portfolio_url"][0]:""; $output .="<strong class='portfolio-meta-key'>".theme_locals('client').": </strong><span> ".$portfolioClient."</span><br>"; $output .="<strong class='portfolio-meta-key'>".theme_locals('date').": </strong><span> ".$portfolioDate."</span><br>"; $output .="<strong class='portfolio-meta-key'>".theme_locals('info').": </strong><span> ".$portfolioInfo."</span><br>"; $output .="<a href='".$portfolioURL."'>".theme_locals('launch_project')."</a><br>"; break; default: $output .=""; }; $output .= '</div>'; if($excerpt_count >= 1){ $output .= '<p class="excerpt">'; $output .= my_string_limit_words($excerpt,$excerpt_count); $output .= '</p>'; } if($more_text_single!=""){ $output .= '<a href="'.get_permalink($post->ID).'" class="btn btn-primary" title="'.get_the_title($post->ID).'">'; $output .= $more_text_single; $output .= '</a>'; } $output .= '</li>'; } $output .= '</ul>'; $output .= '</div>'; return $output; }
function mini_posts_list_shortcode($atts, $content = null) { extract(shortcode_atts(array( 'type' => '', 'numb' => '3', 'thumbs' => '', 'thumb_width' => '', 'thumb_height' => '', 'meta' => '', 'order_by' => '', 'order' => '', 'excerpt_count' => '0', 'custom_class' => '' ), $atts)); $template_url = get_template_directory_uri(); // check what order by method user selected switch ($order_by) { case 'date': $order_by = 'post_date'; break; case 'title': $order_by = 'title'; break; case 'popular': $order_by = 'comment_count'; break; case 'random': $order_by = 'rand'; break; } // check what order method user selected (DESC or ASC) switch ($order) { case 'DESC': $order = 'DESC'; break; case 'ASC': $order = 'ASC'; break; } // thumbnail size $thumb_x = 0; $thumb_y = 0; if (($thumb_width != '') && ($thumb_height != '')) { $thumbs = 'custom_thumb'; $thumb_x = $thumb_width; $thumb_y = $thumb_height; } else { switch ($thumbs) { case 'small': $thumb_x = 110; $thumb_y = 110; break; case 'smaller': $thumb_x = 90; $thumb_y = 90; break; case 'smallest': $thumb_x = 60; $thumb_y = 60; break; } } global $post; global $my_string_limit_words; $args = array( 'post_type' => $type, 'numberposts' => $numb, 'orderby' => $order_by, 'order' => $order ); $posts = get_posts($args); $i = 0; $output = '<ul class="mini-posts-list '.$custom_class.'">'; foreach($posts as $post) { setup_postdata($post); $excerpt = get_the_excerpt(); $attachment_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); $url = $attachment_url['0']; $image = aq_resize($url, $thumb_x, $thumb_y, true); $mediaType = get_post_meta($post->ID, 'tz_portfolio_type', true); $format = get_post_format(); //$output .= '<div class="row-fluid">'; $output .= '<li class="mini-post-holder clearfix">'; //post thumbnail if ($thumbs != 'none') { if ((has_post_thumbnail($post->ID)) && ($format == 'image' || $mediaType == 'Image')) { $output .= '<figure class="a featured-thumbnail thumbnail '.$thumbs.'">'; $output .= '<a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$image.'" alt="'.get_the_title($post->ID).'" />'; $output .= '</a></figure>'; } elseif ($mediaType != 'Video' && $mediaType != 'Audio') { $thumbid = 0; $thumbid = get_post_thumbnail_id($post->ID); $images = get_children( array( 'orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => -1 ) ); if ( $images ) { $k = 0; //looping through the images foreach ( $images as $attachment_id => $attachment ) { //$prettyType = "prettyPhoto[gallery".$i."]"; //if( $attachment->ID == $thumbid ) continue; $image_attributes = wp_get_attachment_image_src( $attachment_id, 'full' ); // returns an array $img = aq_resize($image_attributes[0], $thumb_x, $thumb_y, true); //resize & crop img $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); $image_title = $attachment->post_title; if ( $k == 0 ) { if (has_post_thumbnail($post->ID)) { $output .= '<figure class="featured-thumbnail thumbnail">'; $output .= '<a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$image.'" alt="'.get_the_title($post->ID).'" />'; } else { $output .= '<figure class="featured-thumbnail thumbnail '.$thumbs.'">'; $output .= '<a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$img.'" alt="'.get_the_title($post->ID).'" />'; } } $output .= '</a></figure>'; $k++; } } elseif (has_post_thumbnail($post->ID)) { //$prettyType = 'prettyPhoto'; $output .= '<figure class="featured-thumbnail thumbnail '.$thumbs.'">'; $output .= '<a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$image.'" alt="'.get_the_title($post->ID).'" />'; $output .= '</a></figure>'; } else { // empty_featured_thumb.gif - for post without featured thumbnail $output .= '<figure class="featured-thumbnail thumbnail '.$thumbs.'">'; $output .= '<a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$template_url.'/images/empty_thumb.gif" alt="'.get_the_title($post->ID).'" />'; $output .= '</a></figure>'; } } else { // for Video and Audio post format - no lightbox $output .= '<figure class="featured-thumbnail thumbnail '.$thumbs.'"><a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= '<img src="'.$image.'" alt="'.get_the_title($post->ID).'" />'; $output .= '</a></figure>'; } } //mini post content $output .= '<div class="mini-post-content">'; $output .= '<h4><a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; $output .= get_the_title($post->ID); $output .= '</a></h4>'; if ($meta == 'yes') { // mini post meta $output .= '<div class="mini-post-meta">'; $output .= '<time datetime="'.get_the_time('Y-m-d\TH:i:s', $post->ID).'"> <span>' .get_the_time('d', $post->ID). '</span>' .get_the_time('M', $post->ID). '</time>'; $output .= '</div>'; } if($excerpt_count >= 1){ $output .= '<div class="excerpt">'; $output .= my_string_limit_words($excerpt,$excerpt_count); $output .= '</div>'; } $output .= '</div>'; $output .= '</li>'; $i++; } // end foreach $output .= '</ul><!-- .mini-posts-list (end) -->'; return $output; }
function shortcode_recent_posts($atts, $content = null, $shortcodename = '') { extract(shortcode_atts(array('type' => 'post', 'category' => '', 'custom_category' => '', 'tag' => '', 'post_format' => 'standard', 'num' => '5', 'meta' => 'true', 'thumb' => 'true', 'thumb_width' => '120', 'thumb_height' => '120', 'more_text_single' => '', 'excerpt_count' => '0', 'custom_class' => ''), $atts)); $output = '<ul class="recent-posts ' . $custom_class . ' unstyled">'; global $post; global $my_string_limit_words; $item_counter = 0; // WPML filter $suppress_filters = get_option('suppress_filters'); if ($post_format == 'standard') { $args = array('post_type' => $type, 'category_name' => $category, 'tag' => $tag, $type . '_category' => $custom_category, 'numberposts' => $num, 'orderby' => 'post_date', 'order' => 'DESC', 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-aside', 'post-format-gallery', 'post-format-link', 'post-format-image', 'post-format-quote', 'post-format-audio', 'post-format-video'), 'operator' => 'NOT IN')), 'suppress_filters' => $suppress_filters); } else { $args = array('post_type' => $type, 'category_name' => $category, 'tag' => $tag, $type . '_category' => $custom_category, 'numberposts' => $num, 'orderby' => 'post_date', 'order' => 'DESC', 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-' . $post_format))), 'suppress_filters' => $suppress_filters); } $latest = get_posts($args); foreach ($latest as $k => $post) { //Check if WPML is activated if (defined('ICL_SITEPRESS_VERSION')) { global $sitepress; $post_lang = $sitepress->get_language_for_element($post->ID, 'post_' . $type); $curr_lang = $sitepress->get_current_language(); // Unset not translated posts if ($post_lang != $curr_lang) { unset($latest[$k]); } // Post ID is different in a second language Solution if (function_exists('icl_object_id')) { $post = get_post(icl_object_id($post->ID, $type, true)); } } setup_postdata($post); $excerpt = get_the_excerpt(); $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); $url = $attachment_url['0']; $image = aq_resize($url, $thumb_width, $thumb_height, true); $post_classes = get_post_class(); foreach ($post_classes as $key => $value) { $pos = strripos($value, 'tag-'); if ($pos !== false) { unset($post_classes[$key]); } } $post_classes = implode(' ', $post_classes); $output .= '<li class="recent-posts_li ' . $post_classes . ' list-item-' . $item_counter . ' clearfix">'; //Aside if ($post_format == "aside") { $output .= the_content($post->ID); } elseif ($post_format == "link") { $url = get_post_meta(get_the_ID(), 'tz_link_url', true); $output .= '<a target="_blank" href="' . $url . '">'; $output .= get_the_title($post->ID); $output .= '</a>'; //Quote } elseif ($post_format == "quote") { $quote = get_post_meta(get_the_ID(), 'tz_quote', true); $output .= '<div class="quote-wrap clearfix">'; $output .= '<blockquote>'; $output .= $quote; $output .= '</blockquote>'; $output .= '</div>'; //Image } elseif ($post_format == "image") { if (has_post_thumbnail()) { // $lightbox = get_post_meta(get_the_ID(), 'tz_image_lightbox', TRUE); $src = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), array('9999', '9999'), false, ''); $thumb = get_post_thumbnail_id(); $img_url = wp_get_attachment_url($thumb, 'full'); //get img URL $image = aq_resize($img_url, 200, 120, true); //resize & crop img $output .= '<figure class="thumbnail featured-thumbnail large">'; $output .= '<a class="image-wrap" rel="prettyPhoto" title="' . get_the_title($post->ID) . '" href="' . $src[0] . '">'; $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '" />'; $output .= '<span class="zoom-icon"></span></a>'; $output .= '</figure>'; } //Audio } elseif ($post_format == "audio") { $template_url = get_template_directory_uri(); $id = $post->ID; // get audio attribute $audio_title = get_post_meta(get_the_ID(), 'tz_audio_title', true); $audio_artist = get_post_meta(get_the_ID(), 'tz_audio_artist', true); $audio_format = get_post_meta(get_the_ID(), 'tz_audio_format', true); $audio_url = get_post_meta(get_the_ID(), 'tz_audio_url', true); // Get the URL to the content area. $content_url = untrailingslashit(content_url()); // Find latest '/' in content URL. $last_slash_pos = strrpos($content_url, '/'); // 'wp-content' or something else. $content_dir_name = substr($content_url, $last_slash_pos - strlen($content_url) + 1); $pos = strpos($audio_url, $content_dir_name); if (false === $pos) { $file = $audio_url; } else { $audio_new = substr($audio_url, $pos + strlen($content_dir_name), strlen($audio_url) - $pos); $file = $content_url . $audio_new; } $output .= '<script type="text/javascript"> jQuery(document).ready(function(){ var myPlaylist_' . $id . ' = new jPlayerPlaylist({ jPlayer: "#jquery_jplayer_' . $id . '", cssSelectorAncestor: "#jp_container_' . $id . '" }, [ { title:"' . $audio_title . '", artist:"' . $audio_artist . '", ' . $audio_format . ' : "' . stripslashes(htmlspecialchars_decode($file)) . '"} ], { playlistOptions: {enableRemoveControls: false}, ready: function () {jQuery(this).jPlayer("setMedia", {' . $audio_format . ' : "' . stripslashes(htmlspecialchars_decode($file)) . '", poster: "' . $image . '"}); }, swfPath: "' . $template_url . '/flash", supplied: "' . $audio_format . ', all", wmode:"window" }); }); </script>'; $output .= '<div id="jquery_jplayer_' . $id . '" class="jp-jplayer"></div> <div id="jp_container_' . $id . '" class="jp-audio"> <div class="jp-type-single"> <div class="jp-gui"> <div class="jp-interface"> <div class="jp-progress"> <div class="jp-seek-bar"> <div class="jp-play-bar"></div> </div> </div> <div class="jp-duration"></div> <div class="jp-time-sep"></div> <div class="jp-current-time"></div> <div class="jp-controls-holder"> <ul class="jp-controls"> <li><a href="javascript:;" class="jp-previous" tabindex="1" title="' . __('Previous', CHERRY_PLUGIN_DOMAIN) . '"><span>' . __('Previous', CHERRY_PLUGIN_DOMAIN) . '</span></a></li> <li><a href="javascript:;" class="jp-play" tabindex="1" title="' . __('Play', CHERRY_PLUGIN_DOMAIN) . '"><span>' . __('Play', CHERRY_PLUGIN_DOMAIN) . '</span></a></li> <li><a href="javascript:;" class="jp-pause" tabindex="1" title="' . __('Pause', CHERRY_PLUGIN_DOMAIN) . '"><span>' . __('Pause', CHERRY_PLUGIN_DOMAIN) . '</span></a></li> <li><a href="javascript:;" class="jp-next" tabindex="1" title="' . __('Next', CHERRY_PLUGIN_DOMAIN) . '"><span>' . __('Next', CHERRY_PLUGIN_DOMAIN) . '</span></a></li> <li><a href="javascript:;" class="jp-stop" tabindex="1" title="' . __('Stop', CHERRY_PLUGIN_DOMAIN) . '"><span>' . __('Stop', CHERRY_PLUGIN_DOMAIN) . '</span></a></li> </ul> <div class="jp-volume-bar"> <div class="jp-volume-bar-value"></div> </div> <ul class="jp-toggles"> <li><a href="javascript:;" class="jp-mute" tabindex="1" title="' . __('Mute', CHERRY_PLUGIN_DOMAIN) . '"><span>' . __('Mute', CHERRY_PLUGIN_DOMAIN) . '</span></a></li> <li><a href="javascript:;" class="jp-unmute" tabindex="1" title="' . __('Unmute', CHERRY_PLUGIN_DOMAIN) . '"><span>' . __('Unmute', CHERRY_PLUGIN_DOMAIN) . '</span></a></li> </ul> </div> </div> <div class="jp-no-solution"> <span>' . __('Update Required.', CHERRY_PLUGIN_DOMAIN) . '</span>' . __('To play the media you will need to either update your browser to a recent version or update your ', CHERRY_PLUGIN_DOMAIN) . '<a href="http://get.adobe.com/flashplayer/" target="_blank">' . __('Flash plugin', CHERRY_PLUGIN_DOMAIN) . '</a> </div> </div> </div> <div class="jp-playlist"> <ul> <li></li> </ul> </div> </div>'; $output .= '<div class="entry-content">'; $output .= get_the_content($post->ID); $output .= '</div>'; //Video } elseif ($post_format == "video") { $template_url = get_template_directory_uri(); $id = $post->ID; // get video attribute $video_title = get_post_meta(get_the_ID(), 'tz_video_title', true); $video_artist = get_post_meta(get_the_ID(), 'tz_video_artist', true); $embed = get_post_meta(get_the_ID(), 'tz_video_embed', true); $m4v_url = get_post_meta(get_the_ID(), 'tz_m4v_url', true); $ogv_url = get_post_meta(get_the_ID(), 'tz_ogv_url', true); // Get the URL to the content area. $content_url = untrailingslashit(content_url()); // Find latest '/' in content URL. $last_slash_pos = strrpos($content_url, '/'); // 'wp-content' or something else. $content_dir_name = substr($content_url, $last_slash_pos - strlen($content_url) + 1); $pos1 = strpos($m4v_url, $content_dir_name); if ($pos1 === false) { $file1 = $m4v_url; } else { $m4v_new = substr($m4v_url, $pos1 + strlen($content_dir_name), strlen($m4v_url) - $pos1); $file1 = $content_url . $m4v_new; } $pos2 = strpos($ogv_url, $content_dir_name); if ($pos2 === false) { $file2 = $ogv_url; } else { $ogv_new = substr($ogv_url, $pos2 + strlen($content_dir_name), strlen($ogv_url) - $pos2); $file2 = $content_url . $ogv_new; } // get thumb if (has_post_thumbnail()) { $thumb = get_post_thumbnail_id(); $img_url = wp_get_attachment_url($thumb, 'full'); //get img URL $image = aq_resize($img_url, 770, 380, true); //resize & crop img } if ($embed == '') { $output .= '<script type="text/javascript"> jQuery(document).ready(function(){ var jPlayerObj = jQuery("#jquery_jplayer_' . $id . '") , jPlayerContainer = jQuery("#jp_container_' . $id . '") , isPause = true ; jPlayerObj.jPlayer({ ready: function () { jQuery(this).jPlayer("setMedia", { m4v: "' . stripslashes(htmlspecialchars_decode($file1)) . '", ogv: "' . stripslashes(htmlspecialchars_decode($file2)) . '", poster: "' . $image . '" }); }, swfPath: "' . $template_url . '/flash", solution: "flash, html", supplied: "ogv, m4v, all", cssSelectorAncestor: "#jp_container_' . $id . '", size: { width: "100%", height: "100%" } }); jPlayerObj.on(jQuery.jPlayer.event.ready + ".jp-repeat", function(event) { jQuery("img", this).addClass("poster"); jQuery("video", this).addClass("video"); jQuery("object", this).addClass("flashObject"); jQuery(".video", jPlayerContainer).on("click", function(){ jPlayerObj.jPlayer("pause"); }) }) jPlayerObj.on(jQuery.jPlayer.event.ended + ".jp-repeat", function(event) { isPause = true jQuery(".poster", jPlayerContainer).css({display:"inline"}); jQuery(".video", jPlayerContainer).css({width:"0%", height:"0%"}); jQuery(".flashObject", jPlayerContainer).css({width:"0%", height:"0%"}); jPlayerObj.siblings(".jp-gui").find(".jp-video-play").css({display:"block"}); }); jPlayerObj.on(jQuery.jPlayer.event.play + ".jp-repeat", function(event) { isPause = false emulSwitch(isPause); }); jPlayerObj.on(jQuery.jPlayer.event.pause + ".jp-repeat", function(event) { isPause = true emulSwitch(isPause); }); function emulSwitch(_pause){ if(_pause){ jQuery(".poster", jPlayerContainer).css({display:"none"}); jQuery(".video", jPlayerContainer).css({width:"100%", height:"100%"}); jQuery(".flashObject", jPlayerContainer).css({width:"100%", height:"100%"}); jPlayerObj.siblings(".jp-gui").find(".jp-video-play").css({display:"block"}); }else{ jQuery(".poster", jPlayerContainer).css({display:"none"}); jQuery(".video", jPlayerContainer).css({width:"100%", height:"100%"}); jQuery(".flashObject", jPlayerContainer).css({width:"100%", height:"100%"}); jPlayerObj.siblings(".jp-gui").find(".jp-video-play").css({display:"none"}); } } }); </script>'; $output .= '<div id="jp_container_' . $id . '" class="jp-video fullwidth">'; $output .= '<div class="jp-type-list-parent">'; $output .= '<div class="jp-type-single">'; $output .= '<div id="jquery_jplayer_' . $id . '" class="jp-jplayer"></div>'; $output .= '<div class="jp-gui">'; $output .= '<div class="jp-video-play">'; $output .= '<a href="javascript:;" class="jp-video-play-icon" tabindex="1" title="' . __('Play', CHERRY_PLUGIN_DOMAIN) . '">' . __('Play', CHERRY_PLUGIN_DOMAIN) . '</a></div>'; $output .= '<div class="jp-interface">'; $output .= '<div class="jp-progress">'; $output .= '<div class="jp-seek-bar">'; $output .= '<div class="jp-play-bar">'; $output .= '</div></div></div>'; $output .= '<div class="jp-duration"></div>'; $output .= '<div class="jp-time-sep">/</div>'; $output .= '<div class="jp-current-time"></div>'; $output .= '<div class="jp-controls-holder">'; $output .= '<ul class="jp-controls">'; $output .= '<li><a href="javascript:;" class="jp-play" tabindex="1" title="' . __('Play', CHERRY_PLUGIN_DOMAIN) . '"><span>' . __('Play', CHERRY_PLUGIN_DOMAIN) . '</span></a></li>'; $output .= '<li><a href="javascript:;" class="jp-pause" tabindex="1" title="' . __('Pause', CHERRY_PLUGIN_DOMAIN) . '"><span>' . __('Pause', CHERRY_PLUGIN_DOMAIN) . '</span></a></li>'; $output .= '<li class="li-jp-stop"><a href="javascript:;" class="jp-stop" tabindex="1" title="' . __('Stop', CHERRY_PLUGIN_DOMAIN) . '"><span>' . __('Stop', CHERRY_PLUGIN_DOMAIN) . '</span></a></li>'; $output .= '</ul>'; $output .= '<div class="jp-volume-bar">'; $output .= '<div class="jp-volume-bar-value">'; $output .= '</div></div>'; $output .= '<ul class="jp-toggles">'; $output .= '<li><a href="javascript:;" class="jp-mute" tabindex="1" title="' . __('Mute', CHERRY_PLUGIN_DOMAIN) . '"><span>' . __('Mute', CHERRY_PLUGIN_DOMAIN) . '</span></a></li>'; $output .= '<li><a href="javascript:;" class="jp-unmute" tabindex="1" title="' . __('Unmute', CHERRY_PLUGIN_DOMAIN) . '"><span>' . __('Unmute', CHERRY_PLUGIN_DOMAIN) . '</span></a></li>'; $output .= '</ul>'; $output .= '</div></div>'; $output .= '<div class="jp-no-solution">'; $output .= '<span>' . __('Update Required.', CHERRY_PLUGIN_DOMAIN) . '</span>' . __('To play the media you will need to either update your browser to a recent version or update your ', CHERRY_PLUGIN_DOMAIN) . '<a href="http://get.adobe.com/flashplayer/" target="_blank">' . __('Flash plugin', CHERRY_PLUGIN_DOMAIN) . '</a>'; $output .= '</div></div></div></div>'; $output .= '</div>'; } else { $output .= '<div class="video-wrap">' . stripslashes(htmlspecialchars_decode($embed)) . '</div>'; } if ($excerpt_count >= 1) { $output .= '<div class="excerpt">'; $output .= my_string_limit_words($excerpt, $excerpt_count); $output .= '</div>'; } //Standard } else { if ($thumb == 'true') { if (has_post_thumbnail($post->ID)) { $output .= '<figure class="thumbnail featured-thumbnail"><a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= '<img src="' . $image . '" alt="' . get_the_title($post->ID) . '"/>'; $output .= '</a></figure>'; // post category $output .= '<span class="post_category">'; if ($type != '' && $type != 'post') { $terms = get_the_terms($post_id, $type . '_category'); if ($terms && !is_wp_error($terms)) { $out = array(); foreach ($terms as $term) { $out[] = '<a href="' . get_term_link($term->slug, $type . '_category') . '">' . $term->name . '</a>'; } $output .= join(', ', $out); } } else { $categories = get_the_category($post_id); if ($categories) { $out = array(); foreach ($categories as $category) { $out[] = '<a href="' . get_category_link($category->term_id) . '" title="' . $category->name . '">' . $category->cat_name . '</a> '; } $output .= join(', ', $out); } } $output .= '</span>'; } } $output .= '<h5><a href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; $output .= get_the_title($post->ID); $output .= '</a></h5>'; if ($meta == 'true') { $output .= '<span class="meta">'; $output .= '<span class="post-date">'; $output .= get_the_date(); $output .= '</span>'; $output .= '<span class="post-comments">'; $output .= '<a href="' . get_comments_link($post->ID) . '">'; $output .= get_comments_number($post->ID); $output .= '</a>'; $output .= '</span>'; $output .= '</span>'; } $output .= cherry_get_post_networks(array('post_id' => $post->ID, 'display_title' => false, 'output_type' => 'return')); if ($excerpt_count >= 1) { $output .= '<div class="excerpt">'; $output .= my_string_limit_words($excerpt, $excerpt_count); $output .= '</div>'; } if ($more_text_single != "") { $output .= '<a href="' . get_permalink($post->ID) . '" class="btn btn-primary" title="' . get_the_title($post->ID) . '">'; $output .= $more_text_single; $output .= '</a>'; } } $output .= '<div class="clear"></div>'; $item_counter++; $output .= '</li><!-- .entry (end) -->'; } wp_reset_postdata(); // restore the global $post variable $output .= '</ul><!-- .recent-posts (end) -->'; $output = apply_filters('cherry_plugin_shortcode_output', $output, $atts, $shortcodename); return $output; }
function shortcode_carousel($atts, $content = null, $shortcodename = '') { extract(shortcode_atts(array('title' => '', 'num' => 8, 'type' => 'post', 'thumb' => 'true', 'thumb_width' => 220, 'thumb_height' => 180, 'more_text_single' => '', 'category' => '', 'custom_category' => '', 'excerpt_count' => 12, 'date' => '', 'author' => '', 'comments' => '', 'min_items' => 3, 'spacer' => 18, 'custom_class' => ''), $atts)); switch (strtolower(str_replace(' ', '-', $type))) { case 'blog': $type = 'post'; break; case 'portfolio': $type = 'portfolio'; break; case 'testimonial': $type = 'testi'; break; case 'services': $type = 'services'; break; case 'our-team': $type = 'team'; break; } $carousel_uniqid = uniqid(); $thumb_width = absint($thumb_width); $thumb_height = absint($thumb_height); $excerpt_count = absint($excerpt_count); $itemcount = 0; $output = '<div class="carousel-wrap ' . $custom_class . '">'; if (!empty($title[0])) { $output .= '<h2>' . esc_html($title) . '</h2>'; } $output .= '<div id="carousel-' . $carousel_uniqid . '" class="es-carousel-wrapper">'; $output .= '<div class="es-carousel">'; $output .= '<ul class="es-carousel_list unstyled clearfix">'; // WPML filter $suppress_filters = get_option('suppress_filters'); $args = array('post_type' => $type, 'category_name' => $category, $type . '_category' => $custom_category, 'numberposts' => $num, 'orderby' => 'post_date', 'order' => 'DESC', 'suppress_filters' => $suppress_filters); global $post; // very important $carousel_posts = get_posts($args); foreach ($carousel_posts as $key => $post) { $post_id = $post->ID; //Check if WPML is activated if (defined('ICL_SITEPRESS_VERSION')) { global $sitepress; $post_lang = $sitepress->get_language_for_element($post_id, 'post_' . $type); $curr_lang = $sitepress->get_current_language(); // Unset not translated posts if ($post_lang != $curr_lang) { unset($carousel_posts[$j]); } // Post ID is different in a second language Solution if (function_exists('icl_object_id')) { $post = get_post(icl_object_id($post_id, $type, true)); } } setup_postdata($post); // very important $post_title = esc_html(get_the_title($post_id)); $post_title_attr = esc_attr(strip_tags(get_the_title($post_id))); $format = get_post_format($post_id); $format = empty($format) ? 'format-standart' : 'format-' . $format; if (get_post_meta($post_id, 'tz_link_url', true)) { $post_permalink = $format == 'format-link' ? esc_url(get_post_meta($post_id, 'tz_link_url', true)) : get_permalink($post_id); } else { $post_permalink = get_permalink($post_id); } if (has_excerpt($post_id)) { $excerpt = wp_strip_all_tags(get_the_excerpt()); } else { $excerpt = wp_strip_all_tags(strip_shortcodes(get_the_content())); } $output .= '<li class="es-carousel_li ' . $format . ' clearfix list-item-' . $itemcount . '">'; if ($thumb == 'true') { if (has_post_thumbnail($post_id)) { $attachment_url = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), 'full'); $url = $attachment_url['0']; $image = aq_resize($url, $thumb_width, $thumb_height, true); $output .= '<figure class="featured-thumbnail">'; $output .= '<a href="' . $post_permalink . '" title="' . $post_title . '">'; $output .= '<img src="' . $image . '" alt="' . $post_title . '" />'; $output .= '</a>'; $output .= '</figure>'; } else { $attachments = get_children(array('orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $post_id, 'post_mime_type' => 'image', 'post_status' => null, 'numberposts' => 1)); if ($attachments) { foreach ($attachments as $attachment_id => $attachment) { $image_attributes = wp_get_attachment_image_src($attachment_id, 'full'); $img = aq_resize($image_attributes[0], $thumb_width, $thumb_height, true); $alt = get_post_meta($attachment->ID, '_wp_attachment_image_alt', true); $output .= '<figure class="featured-thumbnail">'; $output .= '<a href="' . $post_permalink . '" title="' . $post_title . '">'; $output .= '<img src="' . $img . '" alt="' . $alt . '" />'; $output .= '</a>'; $output .= '</figure>'; } } } } $output .= '<div class="desc">'; // post date if ($date == 'yes') { $output .= '<time datetime="' . get_the_time('Y-m-d\\TH:i:s', $post_id) . '">' . get_the_date() . '</time>'; } // post author if ($author == 'yes') { $output .= '<em class="author"> <span>' . __('by', CHERRY_PLUGIN_DOMAIN) . '</span> <a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_the_author_meta('display_name') . '</a> </em>'; } // post comment count if ($comments == 'yes') { $comment_count = $post->comment_count; if ($comment_count >= 1) { $comment_count = $comment_count . ' <span>' . __('Comments', CHERRY_PLUGIN_DOMAIN) . '</span>'; } else { $comment_count = $comment_count . ' <span>' . __('Comment', CHERRY_PLUGIN_DOMAIN) . '</span>'; } $output .= '<a href="' . $post_permalink . '#comments" class="comments_link">' . $comment_count . '</a>'; } // post title if (!empty($post_title[0])) { $output .= '<h5><a href="' . $post_permalink . '" title="' . $post_title_attr . '">'; $output .= $post_title; $output .= '</a></h5>'; } // post excerpt if (!empty($excerpt[0])) { $output .= $excerpt_count > 0 ? '<p class="excerpt">' . my_string_limit_words($excerpt, $excerpt_count) . '</p>' : ''; } // post more button $more_text_single = esc_html(wp_kses_data($more_text_single)); if ($more_text_single != '') { $output .= '<a href="' . get_permalink($post_id) . '" class="btn btn-primary" title="' . $post_title_attr . '">'; $output .= __($more_text_single, CHERRY_PLUGIN_DOMAIN); $output .= '</a>'; } $output .= '</div>'; $output .= '</li>'; $itemcount++; } wp_reset_postdata(); // restore the global $post variable $output .= '</ul>'; $output .= '</div></div>'; $output .= '<script> jQuery(document).ready(function(){ jQuery("#carousel-' . $carousel_uniqid . '").elastislide({ imageW : ' . $thumb_width . ', minItems: ' . $min_items . ', speed : 1200, easing : "easeOutQuart", margin : ' . $spacer . ', border : 0 }); })'; $output .= '</script>'; $output .= '</div>'; $output = apply_filters('cherry_plugin_shortcode_output', $output, $atts, $shortcodename); return $output; }
/** * Displays custom posts widget on blog. */ function widget($args, $instance) { global $post; $post_old = $post; // Save the post object. extract($args); $limit = apply_filters('widget_title', $instance['excerpt_length']); $valid_sort_orders = array('date', 'title', 'comment_count', 'rand'); if (in_array($instance['sort_by'], $valid_sort_orders)) { $sort_by = $instance['sort_by']; $sort_order = (bool) $instance['asc_sort_order'] ? 'ASC' : 'DESC'; } else { // by default, display latest first $sort_by = 'date'; $sort_order = 'DESC'; } // Get array of post info. $args = array('showposts' => $instance["num"], 'post_type' => $instance['posttype'], 'orderby' => $sort_by, 'order' => $sort_order, 'category_name' => $category, 'tax_query' => array('relation' => 'AND', array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-aside', 'post-format-gallery', 'post-format-link', 'post-format-image', 'post-format-quote', 'post-format-audio', 'post-format-video'), 'operator' => 'NOT IN'))); $cat_posts = new WP_Query($args); echo $before_widget; // Widget title // If title exist. if ($instance["title"]) { echo $before_title; echo $instance["title"]; echo $after_title; } // Posts list if ($instance['container_class'] == "") { echo "<ul class='post_list'>\n"; } else { echo "<ul class='post_list " . $instance['container_class'] . "'>\n"; } $limittext = $limit; $posts_counter = 0; while ($cat_posts->have_posts()) { $cat_posts->the_post(); $posts_counter++; ?> <?php if ($instance['posttype'] == "testi") { $custom = get_post_custom($post->ID); $testiname = $custom["testimonial-name"][0]; $testiinfo = $custom["testimonial-info"][0]; } $thumb = get_post_thumbnail_id(); $img_url = wp_get_attachment_url($thumb, 'full'); //get img URL $image = aq_resize($img_url, $instance['thumb_w'], $instance['thumb_h'], true); //resize & crop img ?> <li class="cat_post_item-<?php echo $posts_counter; ?> clearfix"> <?php if ($instance["thumb"]) { ?> <figure class="featured-thumbnail"> <?php if ($instance['thumb_as_link']) { ?> <a href="<?php the_permalink(); ?> "> <?php } ?> <?php if ($instance['thumb_w'] !== "" || $instance['thumb_h'] !== "") { ?> <img src="<?php echo $image; ?> " alt="<?php the_title(); ?> " /> <?php } else { ?> <?php the_post_thumbnail(); ?> <?php } ?> <?php if ($instance['thumb_as_link']) { ?> </a> <?php } ?> </figure> <?php } ?> <?php if ($instance['show_title']) { ?> <?php echo $instance["before_post_title"]; ?> <a class="post-title" href="<?php the_permalink(); ?> " rel="bookmark" title="<?php the_title_attribute(); ?> "><?php if ($instance['show_title_date']) { ?> [<?php the_time('m-d-Y'); ?> ]<?php } else { the_title(); } ?> </a><?php echo $instance["after_post_title"]; ?> <?php } ?> <?php if ($instance['comment_num']) { ?> <div class="fright">(<?php comments_number(); ?> )</div> <?php } ?> <?php if ($instance['date']) { ?> <div class="post_meta">Written by <?php the_author_posts_link(); ?> <time datetime="<?php the_time('Y-m-d\\TH:i'); ?> "><?php the_time('l, j F Y'); ?> <?php the_time(); ?> </time></div> <?php } ?> <div class="post_content"> <?php if ($instance['excerpt']) { ?> <?php if ($limittext == "" || $limittext == 0) { ?> <?php if ($instance['excerpt_as_link']) { ?> <a href="<?php the_permalink(); ?> "> <?php } ?> <?php the_excerpt(); ?> <?php if ($instance['excerpt_as_link']) { ?> </a> <?php } ?> <?php } else { ?> <?php if ($instance['excerpt_as_link']) { ?> <a href="<?php the_permalink(); ?> "> <?php } ?> <?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt, $limittext); ?> <?php if ($instance['excerpt_as_link']) { ?> </a> <?php } ?> <?php } ?> <?php } ?> </div> <?php if ($instance['posttype'] == "testi") { ?> <div class="name-testi"><span class="user"><?php echo $testiname; ?> </span><?php if ($testiinfo != '') { echo ', ' . $testiinfo; } ?> </div> <?php } ?> <?php if ($instance['more_link']) { ?> <a href="<?php the_permalink(); ?> " class="<?php if ($instance['more_link_class'] != "") { echo $instance['more_link_class']; } else { ?> link<?php } ?> "><?php if ($instance['more_link_text'] == "") { ?> Read More<?php } else { echo $instance['more_link_text']; } ?> </a> <?php } ?> </li> <?php } ?> <?php echo "</ul>\n"; ?> <?php if ($instance['global_link']) { ?> <a href="<?php echo $instance['global_link_href']; ?> " class="link_show_all"><?php if ($instance['global_link_text'] == "") { ?> View all<?php } else { echo $instance['global_link_text']; } ?> </a> <?php } ?> <?php echo $after_widget; $post = $post_old; // Restore the post object. }
function shortcode_carousel_owl($args) { wp_enqueue_style('owl.carousel', CHERRY_PLUGIN_URL . 'includes/assets/css/owl.carousel.css', false, '0.1', 'all'); wp_enqueue_script('owl.carousel', CHERRY_PLUGIN_URL . 'includes/assets/js/owl.carousel.min.js', array('jquery'), '1.22', true); extract(shortcode_atts(array('title' => '', 'posts_count' => 10, 'post_type' => 'blog', 'post_status' => 'publish', 'visibility_items' => 5, 'thumb' => 'yes', 'thumb_width' => 220, 'thumb_height' => 180, 'more_text_single' => '', 'categories' => '', 'excerpt_count' => 15, 'date' => 'yes', 'author' => 'yes', 'auto_play' => 0, 'display_navs' => 'yes', 'display_pagination' => 'yes', 'custom_class' => ''), $args)); $random_ID = rand(); $thumb = $thumb == 'yes' ? true : false; $date = $date == 'yes' ? true : false; $author = $author == 'yes' ? true : false; $display_navs = $display_navs == 'yes' ? 'true' : 'false'; $display_pagination = $display_pagination == 'yes' ? 'true' : 'false'; switch (strtolower(str_replace(' ', '-', $post_type))) { case 'blog': $post_type = 'post'; break; case 'portfolio': $post_type = 'portfolio'; break; case 'testimonial': $post_type = 'testi'; break; case 'services': $post_type = 'services'; break; case 'our-team': $post_type = 'team'; break; } $get_category_type = $post_type == 'post' ? 'category' : $post_type . '_category'; $categories_ids = array(); foreach (explode(',', str_replace(', ', ',', $categories)) as $category) { $get_cat_id = get_term_by('name', $category, $get_category_type); if ($get_cat_id) { $categories_ids[] = $get_cat_id->term_id; } } $get_query_tax = $categories_ids ? 'tax_query' : ''; if ($posts_count != 0) { $suppress_filters = get_option('suppress_filters'); // WPML filter $args = array('post_status' => $post_status, 'posts_per_page' => $posts_count, 'ignore_sticky_posts' => 1, 'post_type' => $post_type, 'suppress_filters' => $suppress_filters, "{$get_query_tax}" => array(array('taxonomy' => $get_category_type, 'field' => 'id', 'terms' => $categories_ids))); $output = '<div class="carousel-wrap ' . $custom_class . '">'; $output .= $title ? '<h2>' . $title . '</h2>' : ''; $output .= '<div id="owl-carousel-' . $random_ID . '" class="owl-carousel-' . $post_type . ' owl-carousel" data-items="' . $visibility_items . '" data-auto-play="' . $auto_play . '" data-nav="' . $display_navs . '" data-pagination="' . $display_pagination . '">'; query_posts($args); if (have_posts()) { while (have_posts()) { the_post(); // get post thumbnail $thumb = $thumb && has_post_thumbnail() ? wp_get_attachment_url(get_post_thumbnail_id(), 'full') : false; $image = aq_resize($thumb, $thumb_width, $thumb_height, true) or $thumb; // get post excerpt $excerpt = get_the_excerpt(); $output .= '<div class="item">'; $output .= $thumb ? '<figure><a href="' . get_permalink() . '" alt="' . get_the_title() . '"><img data-src="' . $image . '" alt="' . get_the_title() . '"></a></figure>' : ''; $output .= '<div class="desc">'; $output .= $date ? '<time datetime="' . get_the_time('Y-m-d\\TH:i:s') . '">' . get_the_date() . '</time>' : ''; $output .= $author ? '<em class="author">, ' . __('by ', CHERRY_PLUGIN_DOMAIN) . ' <a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_the_author_meta('display_name') . '</a></em>' : ''; $output .= '<h5><a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></h5>'; $output .= $excerpt_count > 0 ? '<p class="excerpt">' . my_string_limit_words($excerpt, $excerpt_count) . '</p>' : ''; $output .= $more_text_single ? '<a href="' . get_permalink() . '" class="btn btn-primary" title="' . get_the_title() . '">' . $more_text_single . '</a>' : ''; $output .= '</div>'; $output .= '</div>'; } } $output .= '</div></div>'; wp_reset_query(); echo $output; } }
</a> <?php } ?> <div class="folio-desc"> <h3><a href="<?php the_permalink(); ?> "><?php $title = the_title('', '', FALSE); echo substr($title, 0, 40); ?> </a></h3> <p class="excerpt"><?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt, 11); ?> </p> <a href="<?php the_permalink(); ?> " class="button">Read more</a> </div> </li> <?php $i++; $addclass = ""; } }
/** @see WP_Widget::widget */ function widget($args, $instance) { extract( $args ); $title = apply_filters('widget_title', $instance['title']); $category = apply_filters('widget_category', $instance['category']); $post_format = apply_filters('widget_post_format', $instance['post_format']); $linktext = apply_filters('widget_linktext', $instance['linktext']); $linkurl = apply_filters('widget_linkurl', $instance['linkurl']); $count = apply_filters('widget_count', $instance['count']); $sort_by = apply_filters('widget_sort_by', $instance['sort_by']); $excerpt_count = apply_filters('widget_excerpt_count', $instance['excerpt_count']); ?> <?php echo $before_widget; ?> <?php if ( $title ) echo $before_title . $title . $after_title; ?> <?php if($post_format == 'post-format-standard') { $args = array( 'showposts' => $count, 'category_name' => $category, 'orderby' => $sort_by, 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array('post-format-aside', 'post-format-gallery', 'post-format-link', 'post-format-image', 'post-format-quote', 'post-format-audio', 'post-format-video'), 'operator' => 'NOT IN' ) ) ); } else { $args = array( 'showposts' => $count, 'category_name' => $category, 'orderby' => $sort_by, 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'post_format', 'field' => 'slug', 'terms' => array($post_format) ) ) ); } ?> <?php $wp_query = new WP_Query( $args ); ?> <ul class="post-list unstyled"> <?php if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post();?> <li class="post-list_li clearfix"> <?php if(has_post_thumbnail()) { ?> <?php $thumb = get_post_thumbnail_id(); $img_url = wp_get_attachment_url( $thumb,'full'); //get img URL $image = aq_resize( $img_url, 100, 100, true ); //resize & crop img ?> <figure class="featured-thumbnail thumbnail"> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo $image ?>" alt="<?php the_title(); ?>" /></a> </figure> <?php } ?> <time datetime="<?php the_time('Y-m-d\TH:i'); ?>"><?php the_time('F j, Y'); ?></time> <h4 class="post-list_h"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php echo theme_locals("permanent_link_to"); ?> <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4> <?php if($excerpt_count!="") { ?> <div class="excerpt"> <?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt,$excerpt_count);?> </div> <?php } ?> <a href="<?php the_permalink() ?>" class="btn btn-primary"><?php echo theme_locals("read_more"); ?></a> </li> <?php endwhile; ?> </ul> <?php endif; ?> <?php $wp_query = null;?> <!-- Link under post cycle --> <?php if($linkurl !=""){?> <a href="<?php echo $linkurl; ?>" class="btn btn-primary"><?php echo $linktext; ?></a> <?php } ?> <?php echo $after_widget; ?> <?php }
function shortcode_recenttesti($atts, $content = null) { extract(shortcode_atts(array('num' => '5', 'thumb' => 'true', 'excerpt_count' => '30'), $atts)); $testi = get_posts('post_type=testi&orderby=post_date&numberposts=' . $num); $output = '<div class="testimonials">'; global $post; global $my_string_limit_words; foreach ($testi as $post) { setup_postdata($post); $excerpt = get_the_excerpt($post->ID); $custom = get_post_custom($post->ID); $testiname = $custom["testimonial-name"][0]; $testiurl = $custom["testimonial-url"][0]; $output .= '<div class="testi_item">'; if ($thumb == 'true') { if (has_post_thumbnail($post->ID)) { $output .= get_the_post_thumbnail($post->ID, 'small-post-thumbnail', array("class" => "thumb")); } } $output .= '<blockquote>'; $output .= '<a href="' . get_permalink($post->ID) . '">'; $output .= my_string_limit_words($excerpt, $excerpt_count); $output .= '</a>'; $output .= '</blockquote>'; $output .= '<div class="name-testi">'; $output .= '<span class="user">'; $output .= $testiname; $output .= '</span>, '; $output .= '<a href="' . $testiurl . '">'; $output .= $testiurl; $output .= '</a>'; $output .= '</div>'; $output .= '</div>'; } $output .= '</div>'; return $output; }
/** @see WP_Widget::widget */ function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $limit = apply_filters('widget_title', $instance['limit']); $category = apply_filters('widget_category', $instance['category']); $count = apply_filters('widget_count', $instance['count']); ?> <?php echo $before_widget; ?> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <?php if ($category == "features") { ?> <div class="features" id="features-cycle"> <?php $limittext = $limit; ?> <?php global $more; $more = 0; ?> <?php query_posts("posts_per_page=" . $count . "&post_type=" . $category); ?> <?php while (have_posts()) { the_post(); ?> <?php $custom = get_post_custom($post->ID); $pageurl = $custom["page-url"][0]; $siteurl = $custom["site-url"][0]; ?> <div class="features_item"> <?php if (has_post_thumbnail()) { ?> <?php echo '<div class="featured-thumbnail">'; the_post_thumbnail(); echo '</div>'; ?> <?php } ?> <?php if ($pageurl != "") { ?> <h5><a href="<?php echo $pageurl; ?> "><?php the_title(); ?> </a></h5> <?php } else { ?> <h5><a href="http://<?php echo $siteurl; ?> "><?php the_title(); ?> </a></h5> <?php } ?> <?php the_excerpt(); ?> </div> <?php } ?> <?php wp_reset_query(); ?> </div> <!-- end of featured --> <?php } else { ?> <script type="text/javascript"> jQuery(function(){ jQuery('#post-cycle').cycle({ pause: 1, fx: 'fade', timeout: 3500 }); }); </script> <div class="post_cycle" id="post-cycle"> <?php $limittext = $limit; ?> <?php global $more; $more = 0; ?> <?php query_posts("posts_per_page=" . $count . "&post_type=" . $category); ?> <?php while (have_posts()) { the_post(); ?> <div class="cycle_item"> <?php if ($limittext == "" || $limittext == 0) { ?> <a href="<?php the_permalink(); ?> "><figure class="featured-thumbnail small"><?php the_post_thumbnail('small-post-thumbnail'); ?> </figure></a> <h5><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h5> <?php the_excerpt(); ?> <?php } else { ?> <a href="<?php the_permalink(); ?> "><figure class="featured-thumbnail small"><?php the_post_thumbnail('small-post-thumbnail'); ?> </figure></a> <h5><a href="<?php the_permalink(); ?> "><?php the_title(); ?> </a></h5> <?php $excerpt = get_the_excerpt(); echo my_string_limit_words($excerpt, $limittext); ?> <?php } ?> </div> <?php } ?> <?php wp_reset_query(); ?> </div> <!-- end of post_cycle --> <?php } ?> <?php echo $after_widget; ?> <?php }