/**
  * Handles shortcode
  * @param $atts
  * @param null $content
  * @return string
  */
 public function handle($atts, $content = null)
 {
     $attributes = shortcode_atts($this->extractShortcodeAttributes($atts), $atts);
     $rounded = '';
     extract($attributes);
     //we grab only 1 product
     $products = $this->getCollection($attributes, array('post_type' => 'product', 'limit' => 1));
     if (!isset($products[0])) {
         return '';
     }
     $p = $products[0];
     $custom = get_post_custom($p->ID);
     $imageSrc = '';
     if ($images == 'yes') {
         if ($rounded == 'yes') {
             $imageSrc = $use_thumbnail == 'yes' ? ct_product_featured_image2_src($p->ID, 'product_thumb', 'product_box_2') : ct_get_feature_image_src($p->ID, 'product_box');
         } else {
             $imageSrc = $use_thumbnail == 'yes' ? ct_product_featured_image2_src($p->ID, 'product_thumb', 'product_box') : ct_get_feature_image_src($p->ID, 'product_box');
         }
     }
     $price = str_replace('.', ',', $this->getFromArray($custom, 'price'));
     $productPrice = explode(",", $price);
     $shortcode = $this->embedShortcode('product_box', array('button_label' => $button_label, 'button_link' => $button_link, 'postscript' => $this->getFromArray($custom, 'postscript'), 'align' => $align, 'style' => $style, 'rounded' => $rounded, 'title' => $p->post_title, 'image' => $imageSrc, 'price' => $showprice == 'yes' || $showprice == 'true' ? $productPrice[0] : '', 'subprice' => isset($productPrice[1]) ? $productPrice[1] : '', 'currency' => $this->getFromArray($custom, 'currency'), 'above_price_text' => $above_price_text), $p->post_content);
     return do_shortcode($shortcode);
 }
 /**
  * Handles shortcode
  * @param $atts
  * @param null $content
  * @return string
  */
 public function handle($atts, $content = null)
 {
     $attributes = shortcode_atts($this->extractShortcodeAttributes($atts), $atts);
     extract($attributes);
     $products = $this->getCollection($attributes, array('post_type' => 'product'));
     $counter = 0;
     $categories = get_term_by('slug', $cat_name, 'product_category');
     if (!$categories) {
         return __('Product category slug not found: ', 'ct_theme') . $cat_name;
     }
     $categoryName = $categories->name;
     $category_description = $categories->description;
     $icons = $this->getDefaultIcons();
     if (isset($icons[$category_image])) {
         $category_image = $icons[$category_image];
     }
     $menuBoxHtml = '[menu_box style="' . $style . '" title="' . $categoryName . '" image="' . $category_image . '" description="' . $category_description . '"]';
     foreach ($products as $p) {
         $custom = get_post_custom($p->ID);
         $counter++;
         $imageSrc = $images == "yes" ? ct_get_feature_image_src($p->ID, 'full') : '';
         $thumb = $images == 'yes' ? ct_product_featured_image2_src($p->ID, 'product_thumb') : '';
         $price = str_replace('.', ',', $custom['price'][0]);
         $productPrice = explode(",", $price);
         $menuBoxHtml .= $this->embedShortcode('menu_box_item', array('thumb' => $thumb, 'image' => $imageSrc, 'separator' => $counter == count($products) ? 'no' : 'yes', 'title' => $p->post_title, 'price' => $productPrice[0], 'subprice' => isset($productPrice[1]) ? $productPrice[1] : ''), $p->post_content) . "\n";
     }
     $menuBoxHtml .= '[/menu_box]';
     return do_shortcode($menuBoxHtml);
 }
 /**
  * Handles shortcode
  * @param $atts
  * @param null $content
  * @return string
  */
 public function handle($atts, $content = null)
 {
     $attributes = shortcode_atts($this->extractShortcodeAttributes($atts), $atts);
     extract($attributes);
     $id = $id == '' ? 'gallery_slider' . rand(100, 1000) : $id;
     $this->addInlineJS($this->flexSliderGetInlineJS($attributes, $id));
     $posts = $this->getCollection($attributes, array('post_type' => $post_type));
     /* Get attached images array*/
     $images = array();
     foreach ($posts as $p) {
         if ($img = ct_get_feature_image_src($p->ID, $image_size)) {
             $images[] = $img;
         }
         $attached_images = $this->getAttachedImages($p->ID, $image_size);
         if (!empty($attached_images)) {
             $images = array_merge($images, $attached_images);
         }
     }
     /*build slider items*/
     $items = '';
     foreach ($images as $img) {
         $imageShortcode = '[img src ="' . $img . '"][/img]';
         $items .= '<li>' . $imageShortcode . '</li>';
     }
     $mainContainerAtts = array('class' => array('flexslider', 'std-slider', 'center-controls', $class), 'data-height' => $height, 'id' => $id);
     $html = '<div ' . $this->buildContainerAttributes($mainContainerAtts, $atts) . '>';
     $html .= '<ul class="slides">' . $items . '</ul>';
     $html .= '</div>';
     return do_shortcode($html);
 }
 /**
  * Returns product image
  * @param $id
  * @param string $name
  * @param string $size
  * @return string
  */
 function ct_product_featured_image2_src($id, $name = 'featured-image-product-2', $size = 'product_thumb')
 {
     $imageUrl = '';
     if (class_exists('kdMultipleFeaturedImages')) {
         $imageUrl = kd_mfi_get_featured_image_url($name, 'product', $size, $id);
     }
     if ($imageUrl == '') {
         $imageUrl = ct_get_feature_image_src($id, $size);
     }
     return $imageUrl;
 }
    /**
     * Handles shortcode
     * @param $atts
     * @param null $content
     * @return string
     */
    public function handle($atts, $content = null)
    {
        $image = '';
        extract(shortcode_atts($this->extractShortcodeAttributes($atts), $atts));
        $args = array('name' => $slug, 'post_type' => 'event', 'post_status' => 'publish', 'numberposts' => 1);
        $my_posts = get_posts($args);
        if ($my_posts) {
            $id = $my_posts[0]->ID;
            $title = $my_posts[0]->post_title;
            $content = get_post_field('post_content', $id);
            if ($id) {
                $custom = get_post_custom($id);
                $permalink = get_permalink($id);
                $date = $custom['date'][0];
                $subtitle = $custom['subtitle'][0];
                $amap = $custom['amap'][0];
                $date = $date ? strtotime($date) : '';
                if ($date != '') {
                    $timestamp = mktime(0, 0, 0, date('m', $date), 1);
                    $month = __(strtoupper(strftime('%b', $timestamp)), 'ct_theme');
                    $day = date('d', $date);
                } else {
                    $month = '';
                    $day = '';
                }
            }
            wp_reset_postdata();
            /*is amap iframe?*/
            preg_match('/src="([^"]+)"/', $amap, $match);
            if ($match == null) {
                $amap .= '&output=embed?iframe=true&width=640&height=480';
            } else {
                $amap = $match[1] . '?iframe=true&width=640&height=480';
            }
            $image = ct_get_option('event_show_featured_image', 0) && ct_get_feature_image_src($id, 'large') ? '<span class="date featureImg"><a target="_blank" data-rel="prettyPhoto" href="' . ct_get_feature_image_src($id, 'large') . '" ><img src="' . ct_get_feature_image_src($id, 'thumb_square') . '" alt=""></a></span>' : '';
            $type2 = $style == '2' ? 'type2' : '';
            $mainContainerAtts = array('class' => array('eventBox', $type2, $class));
            $html = '

        <div ' . $this->buildContainerAttributes($mainContainerAtts, $atts) . '>
        <span class="date">' . $month . '<span>' . $day . '</span></span>

        <h4 class="hdr2">' . $title . '

          <span class="place">' . $content . '</span>
          <span class="time">' . $subtitle . '</span>
        </h4>
        <hr>



        <div class="clearfix"></div>
        <!-- go to http://amap.to/ and create your own map -->
        ' . $image . '<a href="' . htmlentities($amap) . '" data-rel="prettyPhoto" class="mapit"><i></i>' . __('Map it', 'ct_theme') . '</a>
        <a target="_blank" href="http://www.facebook.com/sharer/sharer.php?u=' . $permalink . '" class="shareit"><i></i>' . __('Share it', 'ct_theme') . '</a>

      </div>
		';
            return do_shortcode($html);
        } else {
            return '';
        }
    }
<?php

$imgsrc = ct_get_feature_image_src(get_the_ID(), 'featured_image');
?>

<img src="<?php 
echo $imgsrc;
?>
" alt=" ">


    /**
     * Handles shortcode
     * @param $atts
     * @param null $content
     * @return string
     */
    public function handle($atts, $content = null)
    {
        $attributes = shortcode_atts($this->extractShortcodeAttributes($atts), $atts);
        extract($attributes);
        $recentposts = $this->getCollection($attributes);
        $mainContainerAtts = array('class' => array($widgetmode == 'true' ? 'media-list' : 'recent_posts blog-main', $class));
        if ($widgetmode == 'true') {
            foreach ($recentposts as $p) {
                $picture = '';
                if ($type == 'image') {
                    $picture = '<a class="pull-left" href="' . get_permalink($p) . '">
                            ' . get_the_post_thumbnail($p->ID, array(84, 82)) . '
                             </a>';
                }
                $html .= '
					<li class="media">
						' . $picture . '
						<a href="' . get_permalink($p) . '">
                        <p class="media-heading">' . $p->post_title . '</p>
                        <div class="media-body">
                            <p>' . substr($p->post_content, '0', '70') . '</p>
                        </div>
                        </a>
                        <span class="date">' . get_the_time('M d, Y', $p) . '</span>
			        </li>';
            }
            return do_shortcode('
					' . $headerHtml . '
				<ul ' . $this->buildContainerAttributes($mainContainerAtts, $atts) . '>' . $html . '</ul>');
        } else {
            $index_url = get_permalink(ct_get_option("posts_index_page", '#'));
            $index_button_text = $index_button_text != '' ? '<a href="' . $index_url . '" class="btn btn-block btn-sm btn-default">' . $index_button_text . '</a>' : '';
            /* Build title column */
            $html = '<div ' . $this->buildContainerAttributes($mainContainerAtts, $atts) . '><div class="row withMargin">
            <div class="col-md-3 col-sm-3 col-xs-6">
                    <h3 class="page-title hdr2">' . $title . '</h3>
                    <h4 class="hdr3">' . $subtitle . '</h4>
                    ' . $index_button_text . '
            </div>';
            $is_first_row = true;
            $stop = 3;
            $counter = 0;
            foreach ($recentposts as $p) {
                //$custom = get_post_custom($p->ID);
                $postFormat = get_post_format($p->ID);
                $class = $postFormat == false ? 'blog-item' : 'blog-item format-' . $postFormat;
                /* Bulid article thumb column */
                $html .= '<div class="col-md-3 col-sm-3 col-xs-6"><article id="post-' . $p->ID . '" class="' . $class . '">';
                $comments = wp_count_comments($p->ID)->approved;
                $comments = $comments > 0 ? $comments . ' ' . __('comments', 'ct_theme') : __(' Leave a comment', 'ct_theme');
                $postMetaHtml = '<div class="meta_box">';
                if (ct_get_option("posts_index_show_date", 1)) {
                    $postMetaHtml .= '<span class="meta_date">' . get_the_time('M d, Y', $p) . ' </span>';
                }
                if (ct_get_option("posts_index_show_comments_link", 1)) {
                    $postMetaHtml .= '<span class="meta_comments"><a href="' . get_permalink($p) . '#comments">' . $comments . '</a></span>';
                }
                $postMetaHtml .= '</div>';
                /*get post featured image*/
                $postFeaturedImage = ct_get_feature_image_src($p->ID, 'featured_image_related_posts');
                switch ($postFormat) {
                    case false:
                        //false = post standard (image)
                    //false = post standard (image)
                    case 'image':
                        if ($postFeaturedImage != '') {
                            $html .= '<div class="blog-thumbnail ' . $thumbnail_class . '" ><a href="' . get_permalink($p->ID) . '">';
                            $html .= '<img src="' . $postFeaturedImage . '" alt=" "></a></div>';
                        } else {
                            $html .= '<div class="blog-thumbnail ' . $thumbnail_class . '" ></div>';
                        }
                        $html .= $postMetaHtml;
                        $html .= '<h5 class="entry-title"><a href="' . get_permalink($p->ID) . '">' . $p->post_title . '</a></h5>';
                        break;
                    case 'video':
                        if (get_post_meta($p->ID, 'videoM4V', true) != '') {
                            $embed = get_post_meta($p->ID, 'videoM4V', true);
                        } elseif (get_post_meta($p->ID, 'videoOGV', true) != '') {
                            $embed = get_post_meta($p->ID, 'videoOGV', true);
                        } elseif (get_post_meta($p->ID, 'videoDirect', true) != '') {
                            $embed = get_post_meta($p->ID, 'videoDirect', true);
                        } else {
                            $embed = '';
                        }
                        if ($embed == '') {
                            if ($postFeaturedImage != '') {
                                $html .= '<div class="blog-thumbnail ' . $thumbnail_class . '">';
                                $html .= '<img src="' . ct_get_feature_image_src($p->ID, 'featured_image_related_posts') . '" alt=" ">
                            ';
                                $html .= '</div>';
                            } else {
                                $html .= '<div class="blog-thumbnail ' . $thumbnail_class . '" >
                                <div class="blog-thumbnail ' . $thumbnail_class . '" ></div>
                                ';
                            }
                        } else {
                            if ($postFeaturedImage != '') {
                                $html .= '<div class="blog-thumbnail ' . $thumbnail_class . '">';
                                $html .= '<a href="' . $embed . '" class="popup-iframe">
                                <img src="' . ct_get_feature_image_src($p->ID, 'featured_image_related_posts') . '" alt=" ">
                            </a>';
                                $html .= '</div>';
                            } else {
                                $html .= '<div class="blog-thumbnail ' . $thumbnail_class . '" >
                                <a  href="' . $embed . '" class="popup-iframe">
                                <div class="blog-thumbnail ' . $thumbnail_class . '" ></div>
                            </a>
                                ';
                            }
                        }
                        $html .= $postMetaHtml;
                        $html .= '<h5 class="entry-title"><a href="' . get_permalink($p->ID) . '">' . $p->post_title . '</a>
                        </h5>';
                        break;
                    case 'quote':
                        $html .= '<div class="blog-thumbnail ' . $thumbnail_class . '" ></div>';
                        $html .= $postMetaHtml;
                        $html .= '<blockquote class="inner">';
                        $html .= '<a href="' . get_permalink($p->ID) . '">';
                        $html .= '<p>' . get_post_meta($p->ID, 'quote', true) . '</p>';
                        $html .= '<span class="author">' . get_post_meta($p->ID, 'quoteAuthor', true) . '</span></a>';
                        $html .= '</blockquote>';
                        break;
                    case 'link':
                        $html .= '<div class="blog-thumbnail ' . $thumbnail_class . '" ></div>';
                        $html .= $postMetaHtml;
                        $html .= '<h5 class="entry-title"><a href="' . get_post_meta($p->ID, 'link', true) . '">' . $p->post_content . '</a></h5>';
                        break;
                    case 'image':
                        break;
                    case 'gallery':
                        $html .= '<div class="blog-thumbnail ' . $thumbnail_class . '">';
                        $html .= '[gallery_slider limit="100" ID="' . $p->ID . '"]';
                        $html .= ' </div>';
                        $html .= $postMetaHtml;
                        $html .= '<h5 class="entry-title"><a href="' . get_permalink($p->ID) . '">' . $p->post_title . '</a></h5>';
                        break;
                    case 'audio':
                        if (get_post_meta($p->ID, 'audioOGA', true) != '') {
                            $embed = get_post_meta($p->ID, 'audioOGA', true);
                        } elseif (get_post_meta($p->ID, 'audioMP3', true) != '') {
                            $embed = get_post_meta($p->ID, 'audioMP3', true);
                        }
                        if (empty($embed)) {
                            $html .= '<div class="blog-thumbnail ' . $thumbnail_class . '" ></div>';
                        } else {
                            //$html .= ct_get_the_post_audio($p->ID, 270, 160);
                            $html .= '<div class="blog-thumbnail ' . $thumbnail_class . '" >' . ct_get_the_post_audio($p->ID, 270, 160) . '</div>';
                        }
                        $html .= $postMetaHtml;
                        $html .= '<h5 class="entry-title"><a href="' . get_permalink($p->ID) . '">' . $p->post_title . '</a>';
                        $html .= '</h5>';
                        break;
                    case 'aside':
                        $html .= '<div class="blog-thumbnail ' . $thumbnail_class . '" ></div>';
                        $html .= $postMetaHtml;
                        $html .= '<h5>' . strip_tags($p->post_content) . '<h5>';
                        break;
                }
                $counter++;
                if ($counter == $stop) {
                    // Close article; Close article column; Close Row; Open Row
                    $html .= '</article></div></div><div class="row withMargin">';
                    $counter = 0;
                    $stop = 4;
                    $is_first_row = false;
                } else {
                    if ($counter == $limit) {
                        // Close article; Close article column; Close Row; Open Row
                        $html .= '</article></div></div><div class="row withMargin">';
                        $counter = 0;
                    } else {
                        /* Here, the Row is not closed yet. Next item will be placed in the Row.
                           Close article; Close article column;*/
                        $html .= '</article></div>';
                        if ($is_first_row) {
                            if ($counter == 1) {
                                $html .= "<div class='clearfix visible-xs'></div>";
                            }
                        } else {
                            if ($counter == 2) {
                                $html .= "<div class='clearfix visible-xs'></div>";
                            }
                        }
                    }
                }
            }
            $html .= '</div></div>';
            return do_shortcode($html);
        }
    }