Exemplo n.º 1
0
 /**
  * Render the parent shortcode
  * @param  array $args     Shortcode paramters
  * @param  string $content Content between shortcode
  * @return string          HTML output
  */
 function render($args, $content = '')
 {
     global $smof_data;
     global $evl_options;
     $defaults = T4PCore_Plugin::set_shortcode_defaults(array('class' => '', 'id' => '', 'cat_slug' => '', 'columns' => 3, 'exclude_cats' => '', 'excerpt_length' => '', 'excerpt_words' => '15', 'filters' => 'yes', 'layout' => 'carousel', 'number_posts' => 8, 'animation_direction' => 'left', 'animation_speed' => '', 'animation_type' => '', 'picture_size' => 'fixed'), $args);
     $defaults['filters'] == 'yes' || $defaults['filters'] == 'true' ? $defaults['filters'] = true : ($defaults['filters'] = false);
     extract($defaults);
     self::$args = $defaults;
     // set the image size for the slideshow
     $this->set_image_size();
     if ($excerpt_length || $excerpt_length === '0') {
         $excerpt_words = $excerpt_length;
     }
     $theme = wp_get_theme();
     // gets the current theme
     if ('evolve Plus' == $theme->name || 'evolve Plus' == $theme->parent_theme) {
         $args = array('post_type' => 'evolve_portfolio', 'paged' => 1, 'posts_per_page' => $number_posts, 'has_password' => false);
     } else {
         $args = array('post_type' => 'alora_portfolio', 'paged' => 1, 'posts_per_page' => $number_posts, 'has_password' => false);
     }
     if ($defaults['exclude_cats']) {
         $cats_to_exclude = explode(',', $defaults['exclude_cats']);
     }
     if ($defaults['cat_slug']) {
         $cat_slugs = explode(',', $defaults['cat_slug']);
         if (isset($cats_to_exclude) && $cats_to_exclude) {
             $args['tax_query'] = array('relation' => 'AND', array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $cat_slugs, 'operator' => 'IN'), array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $cats_to_exclude, 'operator' => 'NOT IN'));
         } else {
             $args['tax_query'] = array(array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $cat_slugs));
         }
     }
     wp_reset_query();
     $recent_works = new WP_Query($args);
     $works = '';
     while ($recent_works->have_posts()) {
         $recent_works->the_post();
         $item_classes = $terms = $image_wrapper = $item_content = $buttons = $url = '';
         // set classes, link and target for the image extras content
         $this->set_image_extras(get_the_ID());
         if ($layout == 'carousel') {
             if (has_post_thumbnail()) {
                 if ($smof_data['image_rollover'] || $evl_options['evl_portfolio_rollover']) {
                     $image = get_the_post_thumbnail(get_the_ID(), $this->image_size);
                     $image .= $this->get_image_extras(get_the_ID());
                 } else {
                     $image = sprintf('<a href="%s">%s</a>', get_permalink(get_the_ID()), get_the_post_thumbnail(get_the_ID(), $this->image_size));
                 }
                 $works .= sprintf('<li><div %s>%s</div></li>', T4PCore_Plugin::attributes('recentworks-shortcode-img-div'), $image);
             }
         } else {
             if (has_post_thumbnail() || get_post_meta(get_the_ID(), 'pyre_video', true)) {
                 $item_cats = get_the_terms(get_the_ID(), 'portfolio_category');
                 if ($item_cats) {
                     foreach ($item_cats as $item_cat) {
                         $item_classes .= $item_cat->slug . ' ';
                     }
                 }
                 $permalink = get_permalink();
                 if (has_post_thumbnail()) {
                     $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), $this->image_size);
                     $src = $thumbnail[0];
                     $alt = get_post_field('post_excerpt', get_post_thumbnail_id(get_the_ID()));
                     if ($smof_data['image_rollover'] || $evl_options['evl_portfolio_rollover']) {
                         $image = sprintf('<img %s />', T4PCore_Plugin::attributes('recentworks-shortcode-img', array('src' => $src, 'alt' => $alt)));
                         $image .= $this->get_image_extras(get_the_ID());
                     } else {
                         $image = sprintf('<a href="%s"><img %s /></a>', $permalink, T4PCore_Plugin::attributes('recentworks-shortcode-img', array('src' => $src, 'alt' => $alt)));
                     }
                     $image_wrapper = sprintf('<div %s>%s</div>', T4PCore_Plugin::attributes('recentworks-shortcode-img-div'), $image);
                 }
                 if ($layout == 'grid-with-excerpts') {
                     $stripped_content = strip_shortcodes(t4p_content($excerpt_words, $smof_data['strip_html_excerpt']));
                     if ($columns == 1) {
                         if (get_post_meta(get_the_ID(), 'pyre_project_url', true)) {
                             $url = sprintf('<a href="%s" %s>%s</a>', get_post_meta(get_the_ID(), 'pyre_project_url', true), T4PCore_Plugin::attributes('t4p-button medium default'), __('View Project', 't4p-core'));
                         }
                         $buttons = sprintf('<div %s><a href="%s" %s>%s</a>%s</div>', T4PCore_Plugin::attributes('buttons'), $permalink, T4PCore_Plugin::attributes('t4p-button medium default'), __('Learn More', 't4p-core'), $url);
                     }
                     $item_content = sprintf('<div %s><h2 class="entry-title"><a href="%s">%s</a></h2><h4>%s</h4>%s</div>', T4PCore_Plugin::attributes('portfolio-content'), $permalink, get_the_title(), get_the_term_list(get_the_ID(), 'portfolio_category', '', '<span class="rw-comma">,</span> ', ''), $stripped_content);
                 }
                 $works .= sprintf('<div %s>%s%s</div>', T4PCore_Plugin::attributes('portfolio-item ' . $item_classes), $image_wrapper, $item_content);
             }
         }
     }
     wp_reset_query();
     if ($layout == 'carousel') {
         $html = sprintf('<div %s><div %s><div %s><ul>%s</ul></div><div %s><span %s></span><span %s></span></div></div></div>', T4PCore_Plugin::attributes('recentworks-shortcode'), T4PCore_Plugin::attributes('es-carousel-wrapper t4p-carousel-large'), T4PCore_Plugin::attributes('es-carousel'), $works, T4PCore_Plugin::attributes('es-nav'), T4PCore_Plugin::attributes('es-nav-prev'), T4PCore_Plugin::attributes('es-nav-next'));
     } else {
         $portfolio_category = get_terms('portfolio_category');
         $filter = '';
         $filter_wrapper = '';
         if ($portfolio_category && $filters == true) {
             $filter = sprintf('<li %s><a %s>%s</a></li>', T4PCore_Plugin::attributes('active'), T4PCore_Plugin::attributes('recentworks-shortcode-filter-link', array('data-filter' => '*')), __('All', 't4p-core'));
             foreach ($portfolio_category as $portfolio_cat) {
                 if (isset($args['cat_slug']) && $args['cat_slug']) {
                     $cat_slug = preg_replace('/\\s+/', '', $args['cat_slug']);
                     $cat_slug = explode(',', $cat_slug);
                     if (in_array($portfolio_cat->slug, $cat_slug)) {
                         $filter .= sprintf('<li><a %s>%s</a></li>', T4PCore_Plugin::attributes('recentworks-shortcode-filter-link', array('data-filter' => '.' . $portfolio_cat->slug)), $portfolio_cat->name);
                     }
                 } else {
                     $filter .= sprintf('<li><a %s>%s</a></li>', T4PCore_Plugin::attributes('recentworks-shortcode-filter-link', array('data-filter' => '.' . $portfolio_cat->slug)), $portfolio_cat->name);
                 }
             }
             $filter_wrapper = sprintf('<ul %s>%s</ul>', T4PCore_Plugin::attributes('portfolio-tabs'), $filter);
         }
         $html = sprintf('<div %s>%s<div %s>%s</div></div>', T4PCore_Plugin::attributes('recentworks-shortcode'), $filter_wrapper, T4PCore_Plugin::attributes('portfolio-wrapper'), $works);
     }
     $this->recent_works_counter++;
     return $html;
 }
Exemplo n.º 2
0
 /**
  * Render the parent shortcode
  * @param  array $args     Shortcode paramters
  * @param  string $content Content between shortcode
  * @return string          HTML output
  */
 function render($args, $content = '')
 {
     global $smof_data;
     $defaults = T4PCore_Plugin::set_shortcode_defaults(array('class' => '', 'id' => '', 'cat_id' => '', 'cat_slug' => '', 'columns' => 3, 'excerpt' => 'no', 'exclude_cats' => '', 'excerpt_length' => '', 'excerpt_words' => '15', 'layout' => 'default', 'meta' => 'yes', 'number_posts' => 4, 'strip_html' => 'yes', 'title' => 'yes', 'thumbnail' => 'yes', 'animation_direction' => 'left', 'animation_speed' => '', 'animation_type' => ''), $args);
     extract($defaults);
     self::$args = $defaults;
     $defaults['strip_html'] == 'yes' ? $defaults['strip_html'] = true : ($defaults['strip_html'] = false);
     if ($defaults['number_posts']) {
         $defaults['posts_per_page'] = $defaults['number_posts'];
     }
     if ($defaults['excerpt_length'] || $defaults['excerpt_length'] === '0') {
         $defaults['excerpt_words'] = $defaults['excerpt_length'];
     }
     //check for cats to exclude; needs to be checked via exclude_cats param and '-' prefixed cats on cats param
     //exclution via exclude_cats param
     $cats_to_exclude = explode(',', $defaults['exclude_cats']);
     if ($cats_to_exclude) {
         foreach ($cats_to_exclude as $cat_to_exclude) {
             $idObj = get_category_by_slug($cat_to_exclude);
             if ($idObj) {
                 $cats_id_to_exclude[] = $idObj->term_id;
             }
         }
         if (isset($cats_id_to_exclude) && $cats_id_to_exclude) {
             $defaults['category__not_in'] = $cats_id_to_exclude;
         }
     }
     //setting up cats to be used and exclution using '-' prefix on cats param; transform slugs to ids
     $cat_ids = '';
     $categories = explode(',', $defaults['cat_slug']);
     if (isset($categories) && $categories) {
         foreach ($categories as $category) {
             if ($category) {
                 if (strpos($category, '-') === 0) {
                     $cat_ids .= '-' . get_category_by_slug($category)->cat_ID . ',';
                 } else {
                     $cat_ids .= get_category_by_slug($category)->cat_ID . ',';
                 }
             }
         }
     }
     $defaults['cat'] = substr($cat_ids, 0, -1);
     $defaults['cat'] .= $defaults['cat_id'];
     $items = '';
     $args = array('posts_per_page' => $defaults['number_posts'], 'ignore_sticky_posts' => 1, 'has_password' => false);
     if ($defaults['cat']) {
         $args['cat'] = $defaults['cat'];
     }
     $recent_posts = new WP_Query($args);
     $count = 1;
     while ($recent_posts->have_posts()) {
         $recent_posts->the_post();
         $attachment = $date_box = $slideshow = $slides = $content = '';
         if ($layout == 'icon-on-side') {
             switch (get_post_format()) {
                 case 'gallery':
                     $format_class = 'camera-retro';
                     break;
                 case 'link':
                     $format_class = 'link';
                     break;
                 case 'image':
                     $format_class = 'picture-o';
                     break;
                 case 'quote':
                     $format_class = 'quote-left';
                     break;
                 case 'video':
                     $format_class = 'youtube-play';
                     break;
                 case 'audio':
                     $format_class = 'headphones';
                     break;
                 case 'chat':
                     $format_class = 'comments-o';
                     break;
                 default:
                     $format_class = 'pencil';
                     break;
             }
             $date_box = sprintf('<div %s><div %s><i %s></i></div></div>', T4PCore_Plugin::attributes('date-and-formats'), T4PCore_Plugin::attributes('format-box'), T4PCore_Plugin::attributes('t4p-icon-' . $format_class));
         }
         if ($thumbnail == 'yes' && $layout != 'icon-on-side') {
             if ($layout == 'default') {
                 $image_size = 'recent-posts';
             } elseif ($layout == 'thumbnails-on-side') {
                 $image_size = 'portfolio-two';
             }
             if ($smof_data['legacy_posts_slideshow']) {
                 $args = array('exclude' => get_post_thumbnail_id(), 'numberposts' => $smof_data['posts_slideshow_number'] - 1, 'order' => 'ASC', 'orderby' => 'menu_order', 'post_mime_type' => 'image', 'post_parent' => get_the_ID(), 'post_status' => null, 'post_type' => 'attachment');
                 $attachments = get_posts($args);
                 if ($attachments || has_post_thumbnail() || get_post_meta(get_the_ID(), 'pyre_video', true)) {
                     if (get_post_meta(get_the_ID(), 'pyre_video', true)) {
                         $slides .= sprintf('<li><div %s>%s</div></li>', T4PCore_Plugin::attributes('full-video'), get_post_meta(get_the_ID(), 'pyre_video', true));
                     }
                     if (has_post_thumbnail()) {
                         $attachment_image = wp_get_attachment_image_src(get_post_thumbnail_id(), $image_size);
                         $full_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
                         $attachment_data = wp_get_attachment_metadata(get_post_thumbnail_id());
                         $slides .= sprintf('<li><a href="%s"><img %s/></a></li>', get_permalink(get_the_ID()), T4PCore_Plugin::attributes('recentposts-shortcode-img', array('src' => $attachment_image[0], 'alt' => get_the_title())));
                     }
                     if ($smof_data['posts_slideshow']) {
                         foreach ($attachments as $attachment) {
                             $attachment_image = wp_get_attachment_image_src($attachment->ID, $image_size);
                             $full_image = wp_get_attachment_image_src($attachment->ID, 'full');
                             $attachment_data = wp_get_attachment_metadata($attachment->ID);
                             $slides .= sprintf('<li><a href="%s"><img %s/></a></li>', get_permalink(get_the_ID()), T4PCore_Plugin::attributes('recentposts-shortcode-img', array('src' => $attachment_image[0], 'alt' => $attachment->post_title)));
                         }
                     }
                     $slideshow = sprintf('<div %s><ul %s>%s</ul></div>', T4PCore_Plugin::attributes('recentposts-shortcode-slideshow'), T4PCore_Plugin::attributes('slides'), $slides);
                 }
             } else {
                 if (has_post_thumbnail() || get_post_meta(get_the_ID(), 'pyre_video', true)) {
                     if (get_post_meta(get_the_ID(), 'pyre_video', true)) {
                         $slides .= sprintf('<li><div %s>%s</div></li>', T4PCore_Plugin::attributes('full-video'), get_post_meta(get_the_ID(), 'pyre_video', true));
                     }
                     if (has_post_thumbnail()) {
                         $attachment_image = wp_get_attachment_image_src(get_post_thumbnail_id(), $image_size);
                         $full_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
                         $attachment_data = wp_get_attachment_metadata(get_post_thumbnail_id());
                         $attachment = get_post(get_post_thumbnail_id());
                         $slides .= sprintf('<li><a href="%s"><img %s/></a></li>', get_permalink(get_the_ID()), T4PCore_Plugin::attributes('recentposts-shortcode-img', array('src' => $attachment_image[0], 'alt' => $attachment->post_title)));
                     }
                     if ($smof_data['posts_slideshow']) {
                         $i = 2;
                         while ($i <= $smof_data['posts_slideshow_number']) {
                             $attachment_new_id = kd_mfi_get_featured_image_id('featured-image-' . $i, 'post');
                             if ($attachment_new_id) {
                                 $attachment_image = wp_get_attachment_image_src($attachment_new_id, $image_size);
                                 $full_image = wp_get_attachment_image_src($attachment_new_id, 'full');
                                 $attachment_data = wp_get_attachment_metadata($attachment_new_id);
                                 $slides .= sprintf('<li><a href="%s"><img %s/></a></li>', get_permalink(get_the_ID()), T4PCore_Plugin::attributes('recentposts-shortcode-img', array('src' => $attachment_image[0], 'alt' => '')));
                             }
                             $i++;
                         }
                     }
                     $slideshow = sprintf('<div %s><ul %s>%s</ul></div>', T4PCore_Plugin::attributes('recentposts-shortcode-slideshow'), T4PCore_Plugin::attributes('slides'), $slides);
                 }
             }
         }
         if ($title == 'yes') {
             $content .= sprintf('<h3><a href="%s">%s</a></h3>', get_permalink(get_the_ID()), get_the_title());
         }
         if ($meta == 'yes') {
             $comments = '';
             if (get_comments_number(get_the_ID()) >= 1) {
                 $comments = sprintf('<span %s>|</span><a href="%s">%s %s</a></span>', T4PCore_Plugin::attributes('meta-separator'), get_permalink(get_the_ID()), get_comments_number(get_the_ID()), __('Comments', 't4p-core'));
             }
             $content .= sprintf('<p %s><span><time %s>%s</time></span>%s</p>', T4PCore_Plugin::attributes('meta'), T4PCore_Plugin::attributes('date'), get_the_time($smof_data['date_format'], get_the_ID()), $comments);
         }
         if ($excerpt == 'yes') {
             $content .= t4p_content($excerpt_words, $strip_html);
         }
         $items .= sprintf('<article %s>%s%s<div %s>%s</div></article>', T4PCore_Plugin::attributes('recentposts-shortcode-column'), $date_box, $slideshow, T4PCore_Plugin::attributes('recent-posts-content'), $content);
         $count++;
     }
     $html = sprintf('<div %s><section %s><div %s>%s</div></section></div>', T4PCore_Plugin::attributes('recentposts-shortcode'), T4PCore_Plugin::attributes('recentposts-shortcode-section'), T4PCore_Plugin::attributes('row holder'), $items);
     wp_reset_query();
     return $html;
 }
Exemplo n.º 3
0
 function posts_excerpt()
 {
     $html = '';
     $args = array('posts_per_page' => self::$args['limit'], 'post__not_in' => get_option('sticky_posts'), 'meta_query' => array(array('key' => '_thumbnail_id')));
     if (self::$args['post_id']) {
         $post_ids = explode(',', self::$args['post_id']);
         $args['post__in'] = $post_ids;
     }
     if (self::$args['category']) {
         $args['category_name'] = self::$args['category'];
     }
     $query = new WP_Query($args);
     if ($query->have_posts()) {
         while ($query->have_posts()) {
             $query->the_post();
             $image = wp_get_attachment_url(get_post_thumbnail_id());
             $title = get_post_field('post_excerpt', get_post_thumbnail_id());
             $alt = get_the_title();
             $image_output = sprintf('<img src="%s" alt="%s" />', $image, get_the_title());
             $link_output = sprintf('<a href="%s">%s</a>', get_permalink(), $image_output);
             $title = sprintf('<h2><a href="%s">%s</a></h2>', get_permalink(), get_the_title());
             $excerpt = sprintf('%s', t4p_content(self::$args['excerpt'], true));
             $container = sprintf('<div %s><div %s>%s</div></div>', T4PCore_Plugin::attributes('flexslider-shortcode-title-container'), T4PCore_Plugin::attributes('excerpt-container'), $title . $excerpt);
             $html .= sprintf('<li>%s</li>', $link_output . $container);
         }
     } else {
     }
     wp_reset_query();
     return $html;
 }
                                <span class="vcard" style="display: none;"><span class="fn"><?php 
            the_author_posts_link();
            ?>
</span></span>
                                <span class="updated" style="display: none;"><?php 
            the_time('c');
            ?>
</span>
                                <div class="post-content">
                                    <?php 
            $excerpt_length = $evl_options['evl_portfolio_excerpt_length'];
            $strip_html = $evl_options['evl_portfolio_strip_html'];
            ?>
                                    <?php 
            if ($evl_options['evl_portfolio_excerpt_full_content'] == 'Excerpt') {
                $stripped_content = strip_shortcodes(t4p_content($excerpt_length, $strip_html));
                echo $stripped_content;
            } else {
                the_content();
            }
            ?>
                                </div>
								<div class="buttons">
                                    <a href="<?php 
            echo $permalink;
            ?>
" class="<?php 
            echo sprintf('read-more btn btn-default button medium t4p-button button-medium button-default button-%s button-%s', strtolower($evl_options['evl_shortcode_button_shape']), strtolower($evl_options['evl_shortcode_button_type']));
            ?>
"><?php 
            echo __('Learn More', 'evolve');
Exemplo n.º 5
0
 function loop_content()
 {
     // get the post content according to the chosen kind of delivery
     if (self::$args['excerpt']) {
         $content = t4p_content(self::$args['excerpt_words'], self::$args['strip_html']);
     } else {
         $content = get_the_content();
         $content = apply_filters('the_content', $content);
         $content = str_replace(']]>', ']]&gt;', $content);
     }
     echo $content;
 }