<?php
	// Loads child theme textdomain
	load_child_theme_textdomain( CURRENT_THEME, CHILD_DIR . '/languages' );

	// Loads custom scripts.
	// require_once( 'custom-js.php' );

	// Add the postmeta to Partners
	require_once('theme-partnersmeta.php');

	add_action( 'wp_enqueue_scripts', 'cherry_child_custom_scripts' );
	function cherry_child_custom_scripts() {
		wp_enqueue_script( 'my_script', CHILD_URL . '/js/my_script.js', array( 'jquery' ), '1.0', true );
	}

	add_filter( 'cherry_slider_params', 'child_slider_params' );
    function child_slider_params( $params ) {
        $params['minHeight'] = '"114px"';
        $params['height'] = '"898px"';
    return $params;
    }

	add_filter( 'cherry_stickmenu_selector', 'cherry_change_selector' );
	function cherry_change_selector($selector) {
		$selector = 'header.header';
		return $selector;
	}

	// The excerpt based on words
	function my_string_limit_words_alt($string, $word_limit){
		$words = explode(' ', $string, ($word_limit + 1));
		if( count($words) > $word_limit )
			array_pop($words);
		return implode(' ', $words).'... ';
	}

	// The excerpt based on words
	function my_category_limit_words($string, $word_limit){
		$words = explode(' ', $string, ($word_limit + 1));
		if( count($words) > $word_limit )
			array_pop($words);
		return implode(' ', $words);
	}

	function antwortzeit_move_media () {
	    global $menu; 
	    $menu[14] = $menu[10]; 
	    unset($menu[10]);
	} 
	add_action('admin_menu', 'antwortzeit_move_media');

	/**
	 * Post Grid
	 *
	 */
	if (!function_exists('posts_grid_shortcode')) {

		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', CURRENT_THEME),
				'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;
					$format 		= get_post_format($post_id);

					if ($count > $columns) {
						$count = 1;
						$countul ++;
						$output .= '<ul class="posts-grid row-fluid unstyled '. $custom_class .' ul-item-'.$countul.'">';
					}

					if ($format == '') $format = 'standart';
					$output .= '<li class="'. $spans .' list-item-'.$count.' format-'. $format. '"><div class="inner">';
						if(has_post_thumbnail($post_id) && $mediaType == 'Image') {

							$prettyType = 'prettyPhoto-'.$rand;

							$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).'" />';
							$output .= '</a>';

							if ( ($custom_class == "style-1") && (has_post_thumbnail($post_id)) ) {
								$output .= '<h5 class="extra"><a href="'.get_permalink($post_id).'" title="'.get_the_title($post_id).'">';						
									$output .= my_string_limit_words_alt(get_the_title($post_id), 5);
								$output .= '</a></h5>';
							}	

							$output .= '</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="'.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">';
											$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 thumbnail" style="display:none;">';
										$output .= '<a href="'.get_permalink($post_id).'" title="'.get_the_title($post_id).'">';
									}
									$output .= '</a>';

									if ( ($custom_class == "style-1") && (has_post_thumbnail($post_id)) ) {
										$output .= '<h5 class="extra"><a href="'.get_permalink($post_id).'" title="'.get_the_title($post_id).'">';						
											$output .= my_string_limit_words_alt(get_the_title($post_id), 5);
										$output .= '</a></h5>';
									}	

									$output .= '</figure>';
									$k++;
								}
							} elseif (has_post_thumbnail($post_id)) {
								$prettyType = 'prettyPhoto-'.$rand;
								$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).'" />';
								$output .= '</a>';

								if ( ($custom_class == "style-1") && (has_post_thumbnail($post_id)) ) {
									$output .= '<h5 class="extra"><a href="'.get_permalink($post_id).'" title="'.get_the_title($post_id).'">';						
										$output .= my_string_limit_words_alt(get_the_title($post_id), 5);
									$output .= '</a></h5>';
								}	

								$output .= '</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>';

							if ( ($custom_class == "style-1") && (has_post_thumbnail($post_id)) ) {
								$output .= '<h5 class="extra"><a href="'.get_permalink($post_id).'" title="'.get_the_title($post_id).'">';						
									$output .= my_string_limit_words_alt(get_the_title($post_id), 5);
								$output .= '</a></h5>';
							}	

							$output .= '</figure>';
						}

						$output .= '<div class="clear"></div>';						

						switch ($custom_class) {
							case 'style-1':
								if (!has_post_thumbnail($post_id)) {
									$output .= '<h5><a href="'.get_permalink($post_id).'" title="'.get_the_title($post_id).'">';						
										$output .= my_string_limit_words_alt(get_the_title($post_id), 5);
									$output .= '</a></h5>';
								}
								break;

							case 'style-2':
								$output .= '<h5><a href="'.get_permalink($post_id).'" title="'.get_the_title($post_id).'">';						
									$output .= my_string_limit_words_alt(get_the_title($post_id), 4);
								$output .= '</a></h5>';
								break;

							default:
								$output .= '<h5><a href="'.get_permalink($post_id).'" title="'.get_the_title($post_id).'">';						
									$output .= get_the_title($post_id);
								$output .= '</a></h5>';
								break;
						}

						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') .'">'.my_category_limit_words($term->name, 1).'</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.'">'.my_category_limit_words($category->cat_name, 1).'</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';
								//endif;
								$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 .= '</div></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;
		}
		add_shortcode('posts_grid', 'posts_grid_shortcode');
	}

	//Recent Posts
	if (!function_exists('shortcode_recent_posts')) {

		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>';

					endif;


					//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', CURRENT_THEME).'"><span>'.__('Previous', CURRENT_THEME).'</span></a></li>
															<li><a href="javascript:;" class="jp-play" tabindex="1" title="'.__('Play', CURRENT_THEME).'"><span>'.__('Play', CURRENT_THEME).'</span></a></li>
															<li><a href="javascript:;" class="jp-pause" tabindex="1" title="'.__('Pause', CURRENT_THEME).'"><span>'.__('Pause', CURRENT_THEME).'</span></a></li>
															<li><a href="javascript:;" class="jp-next" tabindex="1" title="'.__('Next', CURRENT_THEME).'"><span>'.__('Next', CURRENT_THEME).'</span></a></li>
															<li><a href="javascript:;" class="jp-stop" tabindex="1" title="'.__('Stop', CURRENT_THEME).'"><span>'.__('Stop', CURRENT_THEME).'</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', CURRENT_THEME).'"><span>'.__('Mute', CURRENT_THEME).'</span></a></li>
															<li><a href="javascript:;" class="jp-unmute" tabindex="1" title="'.__('Unmute', CURRENT_THEME).'"><span>'.__('Unmute', CURRENT_THEME).'</span></a></li>
														</ul>
													</div>
												</div>
												<div class="jp-no-solution">
													<span>'.__('Update Required.', CURRENT_THEME).'</span>'.__('To play the media you will need to either update your browser to a recent version or update your ', CURRENT_THEME).'<a href="http://get.adobe.com/flashplayer/" target="_blank">'.__('Flash plugin', CURRENT_THEME).'</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', CURRENT_THEME).'">'.__('Play', CURRENT_THEME).'</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', CURRENT_THEME).'"><span>'.__('Play', CURRENT_THEME).'</span></a></li>';
								$output .= '<li><a href="javascript:;" class="jp-pause" tabindex="1" title="'.__('Pause', CURRENT_THEME).'"><span>'.__('Pause', CURRENT_THEME).'</span></a></li>';
								$output .= '<li class="li-jp-stop"><a href="javascript:;" class="jp-stop" tabindex="1" title="'.__('Stop', CURRENT_THEME).'"><span>'.__('Stop', CURRENT_THEME).'</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', CURRENT_THEME).'"><span>'.__('Mute', CURRENT_THEME).'</span></a></li>';
								$output .= '<li><a href="javascript:;" class="jp-unmute" tabindex="1" title="'.__('Unmute', CURRENT_THEME).'"><span>'.__('Unmute', CURRENT_THEME).'</span></a></li>';
								$output .= '</ul>';
								$output .= '</div></div>';
								$output .= '<div class="jp-no-solution">';
								$output .= '<span>'.__('Update Required.', CURRENT_THEME).'</span>'.__('To play the media you will need to either update your browser to a recent version or update your ', CURRENT_THEME).'<a href="http://get.adobe.com/flashplayer/" target="_blank">'.__('Flash plugin', CURRENT_THEME).'</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>';
							}
						}
						$output .= '<h5><a href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">';
								$output .= get_the_title($post->ID);
						$output .= '</a></h5>';

						if ($custom_class == "style-3") {
							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 ($custom_class != "style-3") {
							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>';
							}
						}

						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;
		}
		add_shortcode('recent_posts', 'shortcode_recent_posts');
	}

	/**
	 * Carousel Elastislide
	 */
	if ( !function_exists('shortcode_carousel') ) {
		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() ) );
							}

							$partners_url    = get_post_meta($post_id, 'my_partners_url', true);
							$partners_target = get_post_meta($post_id, 'my_partners_target', true);

							$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">';
											if (($type == 'partners') && ($partners_url != '')) {
												$output .= '<a href="' . $partners_url . '" title="' . $post_title . '" target="'.$partners_target.'">';	
											} else {
												$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">';
													if (($type == 'partners') && ($partners_url != '')) {
														$output .= '<a href="' . $partners_url . '" title="' . $post_title . '" target="'.$partners_target.'">';	
													} else {
														$output .= '<a href="' . $post_permalink . '" title="' . $post_title . '">';	
													}
															$output .= '<img src="' . $img . '" alt="' . $alt . '" />';
													$output .= '</a>';
												$output .= '</figure>';
											}
										}
									}

								endif;

								$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">&nbsp;<span>' . __('by', CURRENT_THEME) . '</span>&nbsp;<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', CURRENT_THEME ) . '</span>';
										else :
											$comment_count = $comment_count . ' <span>' . __( 'Comment', CURRENT_THEME ) . '</span>';
										endif;
										$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, CURRENT_THEME );
										$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   : 600,
							easing  : "easeOutQuart",
							margin  : ' . $spacer . ',
							border  : 0
						});
					})';
				$output .= '</script>';
			$output .= '</div>';

			$output = apply_filters( 'cherry_plugin_shortcode_output', $output, $atts, $shortcodename );

			return $output;
		}
		add_shortcode('carousel', 'shortcode_carousel');
	}

	/**
	 * Post List
	 *
	 */
	if (!function_exists('posts_list_shortcode')) {

		function posts_list_shortcode( $atts, $content = null, $shortcodename = '' ) {
			extract(shortcode_atts(array(
				'type'         => 'post',
				'thumbs'       => '',
				'thumb_width'  => '',
				'thumb_height' => '',
				'post_content' => '',
				'numb'         => '5',
				'order_by'     => '',
				'order'        => '',
				'link'         => '',
				'link_text'    => __('Read more', CHERRY_PLUGIN_DOMAIN),
				'tag'          => '',
				'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,
				'tag'              => $tag,
				'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 list-item-'.$i.'">';
					$output .= '<article class="span12 post__holder">';

						//post header
						$output .= '<header class="post-header">';							

							// 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 .= __('Posted in', CHERRY_PLUGIN_DOMAIN).' ';
										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 .= __('Posted in', CHERRY_PLUGIN_DOMAIN).' ';
										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 .= __('by ', CHERRY_PLUGIN_DOMAIN).' ';
							$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.' '.__('Comments', CHERRY_PLUGIN_DOMAIN);
							else : $cc = $cc.' '.__('Comments', CHERRY_PLUGIN_DOMAIN);
							endif;
							$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>';
						}

						$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 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(), 9);
									$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">'.__('Tags', CHERRY_PLUGIN_DOMAIN).": ";
								  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
				wp_reset_postdata(); // restore the global $post variable
			$output .= '</div><!-- .posts-list (end) -->';

			$output = apply_filters( 'cherry_plugin_shortcode_output', $output, $atts, $shortcodename );

			return $output;
		}
		add_shortcode('posts_list', 'posts_list_shortcode');

	}

	//------------------------------------------------------
	//  Related Posts
	//------------------------------------------------------
	if(!function_exists('cherry_related_posts')){
		function cherry_related_posts($args = array()){
			global $post;
			$default = array(
				'post_type' => get_post_type($post),
				'class' => 'related-posts',
				'class_list' => 'related-posts_list',
				'class_list_item' => 'related-posts_item',
				'display_title' => true,
				'display_link' => true,
				'display_thumbnail' => true,
				'width_thumbnail' => 170,
				'height_thumbnail' => 170,
				'before_title' => '<h3 class="related-posts_h">',
				'after_title' => '</h3>',
				'posts_count' => 4
			);
			extract(array_merge($default, $args));

			$post_tags = wp_get_post_terms($post->ID, $post_type.'_tag', array("fields" => "slugs"));
			$tags_type = $post_type=='post' ? 'tag' : $post_type.'_tag' ;
			$suppress_filters = get_option('suppress_filters');// WPML filter
			$blog_related = apply_filters( 'cherry_text_translate', of_get_option('blog_related'), 'blog_related' );
			if ($post_tags && !is_wp_error($post_tags)) {
				$args = array(
					"$tags_type" => implode(',', $post_tags),
					'post_status' => 'publish',
					'posts_per_page' => $posts_count,
					'ignore_sticky_posts' => 1,
					'post__not_in' => array($post->ID),
					'post_type' => $post_type,
					'suppress_filters' => $suppress_filters
					);
				query_posts($args);
				if ( have_posts() ) {
					$output = '<div class="'.$class.'">';
					$output .= $display_title ? $before_title.$blog_related.$after_title : '' ;
					$output .= '<ul class="'.$class_list.' clearfix">';
					while( have_posts() ) {
						the_post();
						$thumb   = has_post_thumbnail() ? get_post_thumbnail_id() : PARENT_URL.'/images/empty_thumb.gif';
						$blank_img = stripos($thumb, 'empty_thumb.gif');
						$img_url = $blank_img ? $thumb : wp_get_attachment_url( $thumb,'full');
						$image   = $blank_img ? $thumb : aq_resize($img_url, $width_thumbnail, $height_thumbnail, true) or $img_url;

						$output .= '<li class="'.$class_list_item.'">';
						$output .= $display_thumbnail ? '<figure class="thumbnail featured-thumbnail"><a href="'.get_permalink().'" title="'.get_the_title().'"><img data-src="'.$image.'" alt="'.get_the_title().'" /></a></figure>': '' ;
						$output .= $display_link ? '<a href="'.get_permalink().'" >'.get_the_title().'</a>': '' ;
						$output .= '</li>';
					}
					$output .= '</ul></div>';
					echo $output;
				}
				wp_reset_query();
			}
		}
	}

	/*-----------------------------------------------------------------------------------*/
	/* Custom Comments Structure
	/*-----------------------------------------------------------------------------------*/
	if ( !function_exists( 'mytheme_comment' ) ) {
		function mytheme_comment($comment, $args, $depth) {
			$GLOBALS['comment'] = $comment;
		?>
		<li <?php comment_class('clearfix'); ?> id="li-comment-<?php comment_ID() ?>">
			<div id="comment-<?php comment_ID(); ?>" class="comment-body clearfix">
				<div class="wrapper">
					<div class="comment-author vcard">
						<?php echo get_avatar( $comment->comment_author_email, 70 ); ?>
						<?php printf('<span class="author">%1$s</span>', get_comment_author_link()) ?>
					</div>
					<?php if ($comment->comment_approved == '0') : ?>
						<em><?php echo theme_locals("your_comment") ?></em>
					<?php endif; ?>
					<div class="extra-wrap">
						<?php comment_text(); ?>

						<div class="extra-wrap">
							<div class="reply">
								<?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
							</div>
							<div class="comment-meta commentmetadata"><?php printf('%1$s', get_comment_date()) ?></div>
						</div>
					</div>
				</div>				
			</div>
	<?php }
	}
?>