/** * Render the shortcode * @param array $args Shortcode paramters * @param string $content Content between shortcode * @return string HTML output */ function render($args, $content = '') { global $woocommerce, $smof_data; $html = ''; if (class_exists('Woocommerce')) { $defaults = FusionCore_Plugin::set_shortcode_defaults(array('class' => '', 'id' => '', 'autoplay' => 'no', 'carousel_layout' => 'title_on_rollover', 'columns' => '5', 'column_spacing' => '0', 'mouse_scroll' => 'no', 'picture_size' => 'fixed', 'scroll_items' => '', 'show_buttons' => 'yes', 'show_cats' => 'yes', 'show_nav' => 'yes', 'show_price' => 'yes', 'post_type' => 'product', 'posts_per_page' => -1, 'meta_key' => '_featured', 'meta_value' => 'yes'), $args); $defaults['show_cats'] == "yes" ? $defaults['show_cats'] = 'enable' : ($defaults['show_cats'] = 'disable'); $defaults['show_price'] == "yes" ? $defaults['show_price'] = true : ($defaults['show_price'] = false); $defaults['show_buttons'] == "yes" ? $defaults['show_buttons'] = true : ($defaults['show_buttons'] = false); extract($defaults); self::$args = $defaults; if ($picture_size == 'fixed') { $featured_image_size = 'shop_single'; } else { $featured_image_size = 'full'; } $products = new WP_Query(self::$args); $product_list = ''; if ($products->have_posts()) { while ($products->have_posts()) { $products->the_post(); $image = $price_tag = $terms = ''; // Title on rollover layout if ($carousel_layout == 'title_on_rollover') { $image = avada_render_first_featured_image_markup(get_the_ID(), $featured_image_size, get_permalink(get_the_ID()), TRUE, $show_price, $show_buttons, $show_cats); // Title below image layout } else { $image = avada_render_first_featured_image_markup(get_the_ID(), $featured_image_size, get_permalink(get_the_ID()), TRUE, FALSE, $show_buttons, 'disable', 'disable'); // Get the post title $image .= sprintf('<h4 %s><a href="%s" target="%s">%s</a></h4>', FusionCore_Plugin::attributes('fusion-carousel-title'), get_permalink(get_the_ID()), '_self', get_the_title()); $image .= '<div class="fusion-carousel-meta">'; // Get the terms if ($show_cats == 'enable') { $image .= get_the_term_list(get_the_ID(), 'product_cat', '', ', ', ''); } // Check if we should render the woo product price if ($show_price) { ob_start(); woocommerce_get_template('loop/price.php'); $image .= sprintf('<div class="fusion-carousel-price">%s</div>', ob_get_clean()); } $image .= '</div>'; } $product_list .= sprintf('<li %s><div %s>%s</div></li>', FusionCore_Plugin::attributes('fusion-carousel-item'), FusionCore_Plugin::attributes('fusion-carousel-item-wrapper'), $image); } } $html = sprintf('<div %s>', FusionCore_Plugin::attributes('woo-featured-products-slider-shortcode')); $html .= sprintf('<div %s>', FusionCore_Plugin::attributes('woo-featured-products-slider-shortcode-carousel')); $html .= sprintf('<div %s>', FusionCore_Plugin::attributes('fusion-carousel-positioner')); $html .= sprintf('<ul %s>', FusionCore_Plugin::attributes('fusion-carousel-holder')); $html .= $product_list; $html .= '</ul>'; // Check if navigation should be shown if ($show_nav == 'yes') { $html .= sprintf('<div %s><span %s></span><span %s></span></div>', FusionCore_Plugin::attributes('fusion-carousel-nav'), FusionCore_Plugin::attributes('fusion-nav-prev'), FusionCore_Plugin::attributes('fusion-nav-next')); } $html .= '</div>'; $html .= '</div>'; $html .= '</div>'; } return $html; }
} // Render the video set in page options if no featured image is present if (!has_post_thumbnail() && fusion_get_page_option('video', $post->ID)) { // For the portfolio one column layout we need a fixed max-width if ($current_page_template == 'portfolio-one-column') { $video_max_width = '540px'; // For all other layouts get the calculated max-width from the image size } else { $video_max_width = $post_featured_image_size_dimensions['width']; } printf('<div class="fusion-image-wrapper fusion-video" style="max-width:%s;">', $video_max_width); echo fusion_get_page_option('video', $post->ID); echo '</div>'; // On every other other layout render the featured image } else { $featured_image_markup = avada_render_first_featured_image_markup($post->ID, $post_featured_image_size, $post_permalink, TRUE); /* Preparing real masonry if ( has_post_thumbnail() ) { $featured_image_markup = str_replace( '"fusion-image-wrapper"', sprintf( '"fusion-image-wrapper" style="background-image: url(%s);"', $featured_image[0] ), $featured_image_markup ); } */ echo $featured_image_markup; } // If we don't have a text layout and not a one column layout only render rich snippets if (!strpos($current_page_template, 'text') && !strpos($current_page_template, 'one')) { echo avada_render_rich_snippets_for_pages(); // If we have a text layout render its contents } else { echo '<div class="fusion-portfolio-content">'; // Render the post title
} // On one column layouts render the video set in page options if no featured image is present if (!has_post_thumbnail() && fusion_get_page_option('video', $post->ID)) { // For the portfolio one column layout we need a fixed max-width if ($portfolio_layout == 'fusion-portfolio-one' && !strpos($portfolio_layout_setting, 'text')) { $video_max_width = '540px'; // For all other layouts get the calculated max-width from the image size } else { $video_max_width = $post_featured_image_size_dimensions['width']; } printf('<div class="fusion-image-wrapper fusion-video" style="max-width:%s;">', $video_max_width); echo fusion_get_page_option('video', $post->ID); echo '</div>'; // On every other other layout render the featured image } else { echo avada_render_first_featured_image_markup($post->ID, $portfolio_image_size, get_permalink($post->ID), TRUE); } // If we don't have a text layout and not a one column layout only render rich snippets if (!strpos($portfolio_layout_setting, 'text') && !strpos($portfolio_layout_setting, 'one')) { echo avada_render_rich_snippets_for_pages(); // If we have a text layout render its contents } else { echo '<div class="fusion-portfolio-content">'; // Render the post title echo avada_render_post_title($post->ID); // Render the post categories echo sprintf('<h4>%s</h4>', get_the_term_list($post->ID, 'portfolio_category', '', ', ', '')); echo avada_render_rich_snippets_for_pages(false); $post_content = ''; ob_start(); /**
/** * 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 = FusionCore_Plugin::set_shortcode_defaults(array('class' => '', 'id' => '', 'autoplay' => 'no', 'boxed_text' => 'unboxed', 'cat_slug' => '', 'carousel_layout' => 'title_on_rollover', 'column_spacing' => '12', 'columns' => 3, 'exclude_cats' => '', 'excerpt_length' => '15', 'excerpt_words' => '', 'filters' => 'yes', 'layout' => 'carousel', 'mouse_scroll' => 'no', 'number_posts' => 8, 'offset' => '', 'picture_size' => 'fixed', 'scroll_items' => '', 'show_nav' => 'yes', 'strip_html' => 'yes', 'animation_direction' => 'left', 'animation_speed' => '', 'animation_type' => ''), $args); if ($defaults['column_spacing'] === '0') { $defaults['column_spacing'] = '0.0'; } if ($defaults['strip_html'] == 'yes') { $defaults['strip_html'] = TRUE; } extract($defaults); self::$args = $defaults; // Set the image size for the slideshow $this->set_image_size(); // As $excerpt_words is deprecated, only use it when explicity set if ($excerpt_words || $excerpt_words === '0') { $excerpt_length = $excerpt_words; } // Transform $cat_slugs to array if (self::$args['cat_slug']) { $cat_slugs = preg_replace('/\\s+/', '', self::$args['cat_slug']); $cat_slugs = explode(',', self::$args['cat_slug']); } else { $cat_slugs = array(); } // Transform $cats_to_exclude to array if (self::$args['exclude_cats']) { $cats_to_exclude = preg_replace('/\\s+/', '', self::$args['cat_slug']); $cats_to_exclude = explode(',', self::$args['exclude_cats']); } else { $cats_to_exclude = array(); } // Initialize the query array $args = array('post_type' => 'avada_portfolio', 'paged' => 1, 'posts_per_page' => $number_posts, 'has_password' => false); if ($defaults['offset']) { $args['offset'] = $offset; } // Check if the are categories that should be excluded if (!empty($cats_to_exclude)) { // Exclude the correct cats from tax_query $args['tax_query'] = array(array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $cats_to_exclude, 'operator' => 'NOT IN')); // Include the correct cats in tax_query if (!empty($cat_slugs)) { $args['tax_query']['relation'] = 'AND'; $args['tax_query'][] = array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $cat_slugs, 'operator' => 'IN'); } } else { // Include the cats from $cat_slugs in tax_query if (!empty($cat_slugs)) { $args['tax_query'] = array(array('taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $cat_slugs)); } } // If placeholder images are disabled, add the _thumbnail_id meta key to the query to only retrieve posts with featured images if (!$smof_data['featured_image_placeholder']) { $args['meta_key'] = '_thumbnail_id'; } wp_reset_query(); $recent_works = new WP_Query($args); $portfolio_posts = ''; // Loop through returned posts // Setup the inner HTML for each elements while ($recent_works->have_posts()) { $recent_works->the_post(); // Reset vars $rich_snippets = $post_classes = $title_terms = $image = $post_title = $post_terms = $separator = $post_content = $buttons = $view_project_button = ''; // For carousels we only need the image and a li wrapper if ($layout == 'carousel') { // Title on rollover layout if ($carousel_layout == 'title_on_rollover') { $show_title = 'default'; // Title below image layout } else { $show_title = 'disable'; // Get the post title $title_terms .= sprintf('<h4 %s><a href="%s" target="%s">%s</a></h4>', FusionCore_Plugin::attributes('fusion-carousel-title'), get_permalink(get_the_ID()), '_self', get_the_title()); // Get the terms $title_terms .= get_the_term_list(get_the_ID(), 'portfolio_category', '<div class="fusion-carousel-meta">', ', ', '</div>'); } // Render the video set in page options if no featured image is present if (!has_post_thumbnail() && fusion_get_page_option('video', get_the_ID())) { $video_max_width = '540px'; $image = sprintf('<div class="fusion-image-wrapper fusion-video" style="max-width:%s;">%s</div>', $video_max_width, fusion_get_page_option('video', get_the_ID())); } else { // Get the post image $image = avada_render_first_featured_image_markup(get_the_ID(), $this->image_size, get_permalink(get_the_ID()), TRUE, FALSE, FALSE, 'disable', $show_title, '', $this->recent_works_counter); } $portfolio_posts .= sprintf('<li %s><div %s>%s%s%s</div></li>', FusionCore_Plugin::attributes('fusion-carousel-item'), FusionCore_Plugin::attributes('fusion-carousel-item-wrapper'), avada_render_rich_snippets_for_pages(), $image, $title_terms); } else { // Get the post permalink $permalink = get_permalink(); // Include the post categories as css classes for later useage with filters $post_categories = get_the_terms(get_the_ID(), 'portfolio_category'); if ($post_categories) { foreach ($post_categories as $post_category) { $post_classes .= urldecode($post_category->slug) . ' '; } } // Add the col-spacing class if needed if ($column_spacing) { $post_classes .= 'fusion-col-spacing'; } // Render the video set in page options if no featured image is present if (!has_post_thumbnail() && fusion_get_page_option('video', get_the_ID())) { $video_max_width = '540px'; $image = sprintf('<div class="fusion-image-wrapper fusion-video" style="max-width:%s;">%s</div>', $video_max_width, fusion_get_page_option('video', get_the_ID())); } else { // Get the post image $image = avada_render_first_featured_image_markup(get_the_ID(), $this->image_size, get_permalink(get_the_ID()), TRUE, FALSE, FALSE, 'disable', 'default', '', $this->recent_works_counter); } // Additional content for grid-with-excerpts layout if ($layout == 'grid-with-excerpts') { // Get the rich snippets, if enabled $rich_snippets = avada_render_rich_snippets_for_pages(false); // Get the post title $post_title = avada_render_post_title(get_the_ID()); // Get the post terms $post_terms = sprintf('<h4>%s</h4>', get_the_term_list(get_the_ID(), 'portfolio_category', '', ', ', '')); // Get the post content ob_start(); /** * fusion_recent_works_shortcode_content hook * * @hooked content - 10 (outputs the post content) */ do_action('fusion_recent_works_shortcode_content'); $stripped_content = ob_get_clean(); // For boxed layouts add a content separator if there is a post content if ($boxed_text == 'boxed' && $stripped_content) { $separator = '<div class="fusion-content-sep"></div>'; } // On one column layouts render the "Learn More" and "View Project" buttons if ($columns == '1') { $classes = sprintf('fusion-button fusion-button-small fusion-button-default fusion-button-%s fusion-button-%s', strtolower($smof_data['button_shape']), strtolower($smof_data['button_type'])); // Add the "Learn More" button $learn_more_button = sprintf('<a href="%s" %s>%s</a>', $permalink, FusionCore_Plugin::attributes($classes), __('Learn More', 'fusion-core')); // If there is a project url, add the "View Project" button $view_project_button = ''; if (fusion_get_page_option('project_url', get_the_ID())) { $view_project_button = sprintf('<a href="%s" %s>%s</a>', fusion_get_page_option('project_url', get_the_ID()), FusionCore_Plugin::attributes($classes), __('View Project', 'fusion-core')); } // Wrap buttons $buttons = sprintf('<div %s>%s%s</div>', FusionCore_Plugin::attributes('fusion-portfolio-buttons'), $learn_more_button, $view_project_button); } // Put it all together $post_content = sprintf('<div %s>%s%s%s<div %s>%s%s</div></div>', FusionCore_Plugin::attributes('fusion-portfolio-content'), $post_title, $post_terms, $separator, FusionCore_Plugin::attributes('fusion-post-content'), $stripped_content, $buttons); } else { // Get the rich snippets for grid layout without excerpts $rich_snippets = avada_render_rich_snippets_for_pages(); } $portfolio_posts .= sprintf('<div %s><div %s>%s%s%s</div></div>', FusionCore_Plugin::attributes('fusion-portfolio-post ' . $post_classes), FusionCore_Plugin::attributes('fusion-portfolio-content-wrapper'), $rich_snippets, $image, $post_content); } } // end while wp_reset_query(); // Wrap all the portfolio posts with the appropriate HTML markup // Carousel layout if ($layout == 'carousel') { $main_carousel = sprintf('<ul %s>%s</ul>', FusionCore_Plugin::attributes('fusion-carousel-holder'), $portfolio_posts); // Check if navigation should be shown $navigation = ''; if ($show_nav == 'yes') { $navigation = sprintf('<div %s><span %s></span><span %s></span></div>', FusionCore_Plugin::attributes('fusion-carousel-nav'), FusionCore_Plugin::attributes('fusion-nav-prev'), FusionCore_Plugin::attributes('fusion-nav-next')); } $html = sprintf('<div %s><div %s><div %s>%s%s</div></div></div>', FusionCore_Plugin::attributes('recentworks-shortcode'), FusionCore_Plugin::attributes('recentworks-shortcode-carousel'), FusionCore_Plugin::attributes('fusion-carousel-positioner'), $main_carousel, $navigation); // Grid layouts } else { // Reset vars $filter_wrapper = $filter = $styles = ''; // Setup the filters, if enabled $portfolio_categories = get_terms('portfolio_category'); // Check if filters should be displayed if ($portfolio_categories && $filters != 'no') { // Check if the "All" filter should be displayed if ($filters != 'yes-without-all') { $filter = sprintf('<li %s><a %s>%s</a></li>', FusionCore_Plugin::attributes('fusion-filter fusion-filter-all fusion-active'), FusionCore_Plugin::attributes('recentworks-shortcode-filter-link', array('data-filter' => '*')), __('All', 'fusion-core')); $first_filter = FALSE; } else { $first_filter = TRUE; } // Loop through categories foreach ($portfolio_categories as $portfolio_category) { // Only display filters of non excluded categories if (!in_array($portfolio_category->slug, $cats_to_exclude)) { // Check if categories have been chosen if (!empty(self::$args['cat_slug'])) { // Only display filters for explicitly included categories if (in_array($portfolio_category->slug, $cat_slugs)) { // Set the first category filter to active, if the all filter isn't shown $active_class = ''; if ($first_filter) { $active_class = ' fusion-active'; $first_filter = FALSE; } $filter .= sprintf('<li %s><a %s>%s</a></li>', FusionCore_Plugin::attributes('fusion-filter fusion-hidden' . $active_class), FusionCore_Plugin::attributes('recentworks-shortcode-filter-link', array('data-filter' => '.' . $portfolio_category->slug)), $portfolio_category->name); } // Display all categories } else { // Set the first category filter to active, if the all filter isn't shown $active_class = ''; if ($first_filter) { $active_class = ' fusion-active'; $first_filter = FALSE; } $filter .= sprintf('<li %s><a %s>%s</a></li>', FusionCore_Plugin::attributes('fusion-filter fusion-hidden' . $active_class), FusionCore_Plugin::attributes('recentworks-shortcode-filter-link', array('data-filter' => '.' . $portfolio_category->slug)), $portfolio_category->name); } } } // end foreach // Wrap filters $filter_wrapper = sprintf('<ul %s>%s</ul>', FusionCore_Plugin::attributes('fusion-filters'), $filter); } // For column spacing set needed css if ($column_spacing) { $styles = sprintf('<style type="text/css">.fusion-recent-works-%s .fusion-portfolio-wrapper .fusion-col-spacing{padding:%spx;}</style>', $this->recent_works_counter, $column_spacing / 2); } // Put it all together $html = sprintf('<div %s>%s%s<div %s>%s</div></div>', FusionCore_Plugin::attributes('recentworks-shortcode'), $filter_wrapper, $styles, FusionCore_Plugin::attributes('recentworks-shortcode-portfolio-wrapper'), $portfolio_posts); } $this->recent_works_counter++; return $html; }
/** * Render the shortcode * * @param array $args Shortcode paramters * @param string $content Content between shortcode * * @return string HTML output */ function render($args, $content = '') { global $woocommerce, $smof_data; $defaults = FusionCore_Plugin::set_shortcode_defaults(array('class' => '', 'id' => '', 'autoplay' => 'no', 'carousel_layout' => 'title_on_rollover', 'cat_slug' => '', 'columns' => '5', 'column_spacing' => '13', 'mouse_scroll' => 'no', 'number_posts' => 10, 'picture_size' => 'fixed', 'scroll_items' => '', 'show_buttons' => 'yes', 'show_cats' => 'yes', 'show_nav' => 'yes', 'show_price' => 'yes'), $args); $defaults['show_cats'] == "yes" ? $defaults['show_cats'] = 'enable' : ($defaults['show_cats'] = 'disable'); $defaults['show_price'] == "yes" ? $defaults['show_price'] = true : ($defaults['show_price'] = false); $defaults['show_buttons'] == "yes" ? $defaults['show_buttons'] = true : ($defaults['show_buttons'] = false); extract($defaults); self::$args = $defaults; $html = ''; $buttons = ''; if (class_exists('Woocommerce')) { $items_in_cart = array(); if ($woocommerce->cart && $woocommerce->cart->get_cart() && is_array($woocommerce->cart->get_cart())) { foreach ($woocommerce->cart->get_cart() as $cart) { $items_in_cart[] = $cart['product_id']; } } $design_class = 'fusion-' . Avada()->settings->get('woocommerce_product_box_design') . '-product-image-wrapper'; $number_posts = (int) $number_posts; $args = array('post_type' => 'product', 'posts_per_page' => $number_posts, 'meta_query' => array(array('key' => '_thumbnail_id', 'compare' => '!=', 'value' => null))); if ($cat_slug) { $cat_id = explode('|', $cat_slug); $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => $cat_id)); } if ($picture_size == 'fixed') { $featured_image_size = 'related-img'; } else { $featured_image_size = 'full'; } $products = new WP_Query($args); $product_list = ''; if ($products->have_posts()) { while ($products->have_posts()) { $products->the_post(); $id = get_the_ID(); $in_cart = in_array($id, $items_in_cart); $image = $price_tag = $terms = ''; // Title on rollover layout if ($carousel_layout == 'title_on_rollover') { $image = avada_render_first_featured_image_markup(get_the_ID(), $featured_image_size, get_permalink(get_the_ID()), TRUE, $show_price, $show_buttons, $show_cats); // Title below image layout } else { if ($show_buttons == 'yes') { $image = avada_render_first_featured_image_markup(get_the_ID(), $featured_image_size, get_permalink(get_the_ID()), TRUE, FALSE, $show_buttons, 'disable', 'disable'); } else { $image = avada_render_first_featured_image_markup(get_the_ID(), $featured_image_size, get_permalink(get_the_ID()), TRUE, FALSE, $show_buttons, 'disable', 'disable', '', '', 'no'); } // Get the post title $image .= sprintf('<h4 %s><a href="%s" target="%s">%s</a></h4>', FusionCore_Plugin::attributes('fusion-carousel-title'), get_permalink(get_the_ID()), '_self', get_the_title()); $image .= '<div class="fusion-carousel-meta">'; // Get the terms if ($show_cats == 'enable') { $image .= get_the_term_list(get_the_ID(), 'product_cat', '', ', ', ''); } // Check if we should render the woo product price if ($show_price) { ob_start(); woocommerce_get_template('loop/price.php'); $image .= sprintf('<div class="fusion-carousel-price">%s</div>', ob_get_clean()); } $image .= '</div>'; } if ($in_cart) { $product_list .= sprintf('<li %s><div class="%s"><div %s>%s</div></div></li>', FusionCore_Plugin::attributes('fusion-carousel-item'), $design_class . ' fusion-item-in-cart', FusionCore_Plugin::attributes('fusion-carousel-item-wrapper'), $image); } else { $product_list .= sprintf('<li %s><div class="%s"><div %s>%s</div></div></li>', FusionCore_Plugin::attributes('fusion-carousel-item'), $design_class, FusionCore_Plugin::attributes('fusion-carousel-item-wrapper'), $image); } } } wp_reset_query(); $html = sprintf('<div %s>', FusionCore_Plugin::attributes('woo-product-slider-shortcode')); $html .= sprintf('<div %s>', FusionCore_Plugin::attributes('woo-product-slider-shortcode-carousel')); $html .= sprintf('<div %s>', FusionCore_Plugin::attributes('fusion-carousel-positioner')); $html .= sprintf('<ul %s>', FusionCore_Plugin::attributes('fusion-carousel-holder')); $html .= $product_list; $html .= '</ul>'; // Check if navigation should be shown if ($show_nav == 'yes') { $html .= sprintf('<div %s><span %s></span><span %s></span></div>', FusionCore_Plugin::attributes('fusion-carousel-nav'), FusionCore_Plugin::attributes('fusion-nav-prev'), FusionCore_Plugin::attributes('fusion-nav-next')); } $html .= '</div>'; $html .= '</div>'; $html .= '</div>'; } return $html; }
/** * Render related posts carousel * @param string $post_type The post type to determine correct related posts and headings * * @return string HTML markup to display related posts **/ function avada_render_related_posts($post_type = 'post') { $html = ''; // Set the needed variables according to post type if ($post_type == 'post') { $theme_option_name = 'related_posts'; $main_heading = __('Related Posts', 'Avada'); } elseif ($post_type == 'avada_portfolio') { $theme_option_name = 'portfolio_related_posts'; $main_heading = __('Related Projects', 'Avada'); } // Check if related posts should be shown if (fusion_get_option($theme_option_name, 'related_posts', get_the_ID()) == 'yes' || fusion_get_option($theme_option_name, 'related_posts', get_the_ID()) == '1') { if ($post_type == 'post') { $related_posts = fusion_get_related_posts(get_the_ID(), Avada()->settings->get('number_related_posts')); } elseif ($post_type == 'avada_portfolio') { $related_posts = fusion_get_related_projects(get_the_ID(), Avada()->settings->get('number_related_posts')); } // If there are related posts, display them if ($related_posts->have_posts()) { $html .= '<div class="related-posts single-related-posts">'; ob_start(); echo do_shortcode(sprintf('[title size="3" content_align="left" style_type="default"]%s[/title]', $main_heading)); $html .= ob_get_clean(); // Get the correct image size if ('cropped' == Avada()->settings->get('related_posts_image_size')) { $featured_image_size = 'fixed'; $data_image_size = 'fixed'; } else { $featured_image_size = 'full'; $data_image_size = 'auto'; } // Set the meta content variable if ('title_on_rollover' == Avada()->settings->get('related_posts_layout')) { $data_meta_content = 'no'; } else { $data_meta_content = 'yes'; } // Set the autoplay variable if (Avada()->settings->get('related_posts_autoplay')) { $data_autoplay = 'yes'; } else { $data_autoplay = 'no'; } // Set the touch scroll variable if (Avada()->settings->get('related_posts_swipe')) { $data_swipe = 'yes'; } else { $data_swipe = 'no'; } $carousel_item_css = ''; if (sizeof($related_posts->posts) < Avada()->settings->get('related_posts_columns')) { $carousel_item_css = ' style="max-width: 300px;"'; } $html .= sprintf('<div class="fusion-carousel" data-imagesize="%s" data-metacontent="%s" data-autoplay="%s" data-touchscroll="%s" data-columns="%s" data-itemmargin="%s" data-itemwidth="180" data-touchscroll="yes" data-scrollitems="%s">', $data_image_size, $data_meta_content, $data_autoplay, $data_swipe, Avada()->settings->get('related_posts_columns'), Avada()->settings->get('related_posts_column_spacing'), Avada()->settings->get('related_posts_swipe_items')); $html .= '<div class="fusion-carousel-positioner">'; $html .= '<ul class="fusion-carousel-holder">'; // Loop through related posts while ($related_posts->have_posts()) { $related_posts->the_post(); $html .= sprintf('<li class="fusion-carousel-item"%s>', $carousel_item_css); $html .= '<div class="fusion-carousel-item-wrapper">'; // Title on rollover layout if ('title_on_rollover' == Avada()->settings->get('related_posts_layout')) { $html .= avada_render_first_featured_image_markup(get_the_ID(), $featured_image_size, get_permalink(get_the_ID()), TRUE, FALSE, FALSE, 'disable', 'default', 'related'); // Title below image layout } else { $html .= avada_render_first_featured_image_markup(get_the_ID(), $featured_image_size, get_permalink(get_the_ID()), TRUE, FALSE, FALSE, 'disable', 'disable', 'related'); // Get the post title $html .= sprintf('<h4 class="fusion-carousel-title"><a href="%s"%s>%s</a></h4>', get_permalink(get_the_ID()), '_self', get_the_title()); $html .= '<div class="fusion-carousel-meta">'; $html .= sprintf('<span class="fusion-date">%s</span>', get_the_time(Avada()->settings->get('date_format'), get_the_ID())); $html .= '<span class="fusion-inline-sep">|</span>'; $comments = $comments_link = ''; ob_start(); comments_popup_link(__('0 Comments', 'Avada'), __('1 Comment', 'Avada'), '% ' . __('Comments', 'Avada')); $comments_link = ob_get_clean(); $html .= sprintf('<span>%s</span>', $comments_link); $html .= '</div>'; // fusion-carousel-meta } $html .= '</div>'; // fusion-carousel-item-wrapper $html .= '</li>'; } $html .= '</ul>'; // fusion-carousel-holder // Add navigation if needed if (Avada()->settings->get('related_posts_navigation')) { $html .= '<div class="fusion-carousel-nav"><span class="fusion-nav-prev"></span><span class="fusion-nav-next"></span></div>'; } $html .= '</div>'; // fusion-carousel-positioner $html .= '</div>'; // fusion-carousel $html .= '</div>'; // related-posts wp_reset_postdata(); } } return $html; }
function avada_woocommerce_thumbnail() { global $product, $woocommerce; $items_in_cart = array(); if ($woocommerce->cart && $woocommerce->cart->get_cart() && is_array($woocommerce->cart->get_cart())) { foreach ($woocommerce->cart->get_cart() as $cart) { $items_in_cart[] = $cart['product_id']; } } $id = get_the_ID(); $in_cart = in_array($id, $items_in_cart); $size = 'shop_catalog'; $post_permalink = get_permalink(); $classes = ''; if ($in_cart) { $classes = 'fusion-item-in-cart'; } $featured_image_markup = avada_render_first_featured_image_markup($id, $size, $post_permalink, TRUE, FALSE, TRUE, 'disable', 'disable', '', '', 'yes', TRUE); echo '<div class="fusion-clean-product-image-wrapper ' . $classes . '">'; echo $featured_image_markup; echo '</div>'; }
Avada()->images->set_grid_image_meta(array('layout' => strtolower($layout), 'columns' => '2')); } elseif (false !== strpos($layout, 'large') && 'full' == $size) { Avada()->images->set_grid_image_meta(array('layout' => strtolower($layout), 'columns' => '1')); } ?> <?php if (has_post_thumbnail()) { ?> <?php $full_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); ?> <?php $attachment_data = wp_get_attachment_metadata(get_post_thumbnail_id()); ?> <li><?php echo avada_render_first_featured_image_markup($post->ID, $size, $permalink); ?> </li> <?php } ?> <?php $i = 2; ?> <?php while ($i <= Avada()->settings->get('posts_slideshow_number')) { ?> <?php $attachment_id = kd_mfi_get_featured_image_id('featured-image-' . $i, 'post'); ?> <?php
?> <li class="fusion-carousel-item"<?php echo $carousel_item_css; ?> > <div class="fusion-carousel-item-wrapper"> <?php if ('title_on_rollover' == Avada()->settings->get('related_posts_layout')) { $display_post_title = 'default'; } else { $display_post_title = 'disable'; } if ($data_image_size == 'auto') { Avada()->images->set_grid_image_meta(array('layout' => 'related-posts', 'columns' => Avada()->settings->get('related_posts_columns'))); } echo avada_render_first_featured_image_markup(get_the_ID(), $featured_image_size, get_permalink(get_the_ID()), true, false, false, 'disable', $display_post_title, 'related'); Avada()->images->set_grid_image_meta(array()); ?> <?php if ('title_below_image' == Avada()->settings->get('related_posts_layout')) { // Title on rollover layout ?> <?php /** * Get the post title */ ?> <h4 class="fusion-carousel-title"> <a href="<?php