Exemple #1
0
function avia_woocommerce_thumbnail($asdf)
{
    global $product, $avia_config;
    $rating = $product->get_rating_html();
    //get rating
    $id = get_the_ID();
    $size = 'shop_catalog';
    echo "<div class='thumbnail_container'>";
    echo avia_woocommerce_gallery_first_thumbnail($id, $size);
    echo get_the_post_thumbnail($id, $size);
    if (!empty($rating)) {
        echo "<span class='rating_container'>" . $rating . "</span>";
    }
    if ($product->product_type == 'simple') {
        echo "<span class='cart-loading'></span>";
    }
    echo "</div>";
}
Exemple #2
0
 function prepare_loop_from_entries()
 {
     $this->loop = array();
     if (empty($this->entries) || empty($this->entries->posts)) {
         return;
     }
     $tagTax = "post_tag";
     $date_format = get_option('date_format');
     foreach ($this->entries->posts as $key => $entry) {
         $overlay_img = $custom_url = false;
         $img_size = 'masonry';
         $author = apply_filters('avf_author_name', get_the_author_meta('display_name', $entry->post_author), $entry->post_author);
         $this->loop[$key]['text_before'] = "";
         $this->loop[$key]['text_after'] = "";
         $this->loop[$key]['ID'] = $id = $entry->ID;
         $this->loop[$key]['post_type'] = $entry->post_type;
         $this->loop[$key]['thumb_ID'] = get_post_thumbnail_id($id);
         $this->loop[$key]['the_title'] = get_the_title($id);
         $this->loop[$key]['url'] = get_permalink($id);
         $this->loop[$key]['date'] = "<span class='av-masonry-date meta-color updated'>" . get_the_time($date_format, $id) . "</span>";
         $this->loop[$key]['author'] = "<span class='av-masonry-author meta-color vcard author'><span class='fn'>" . __('by', 'avia_framework') . ' ' . $author . "</span></span>";
         $this->loop[$key]['class'] = get_post_class("av-masonry-entry isotope-item", $id);
         $this->loop[$key]['content'] = $entry->post_excerpt;
         $this->loop[$key]['description'] = !empty($entry->post_content) ? $entry->post_content : $entry->post_excerpt;
         if (empty($this->loop[$key]['content'])) {
             $this->loop[$key]['content'] = avia_backend_truncate($entry->post_content, apply_filters('avf_masonry_excerpt_length', 60), apply_filters('avf_masonry_excerpt_delimiter', " "), "…", true, '');
         }
         //post type specific
         switch ($entry->post_type) {
             case 'post':
                 $post_format = get_post_format($id) ? get_post_format($id) : 'standard';
                 $this->loop[$key] = apply_filters('post-format-' . $post_format, $this->loop[$key]);
                 $this->loop[$key]['text_after'] .= $this->loop[$key]['date'];
                 $this->loop[$key]['text_after'] .= '<span class="av-masonry-text-sep text-sep-author">/</span>';
                 $this->loop[$key]['text_after'] .= $this->loop[$key]['author'];
                 switch ($post_format) {
                     case 'quote':
                     case 'link':
                     case 'image':
                     case 'gallery':
                         if (!$this->loop[$key]['thumb_ID']) {
                             $this->loop[$key]['text_before'] = av_icon_display($post_format);
                         }
                         break;
                     case 'audio':
                     case 'video':
                         if (!$this->loop[$key]['thumb_ID']) {
                             $this->loop[$key]['text_before'] = av_icon_display($post_format);
                         } else {
                             $this->loop[$key]['text_before'] = av_icon_display($post_format, 'av-masonry-media');
                         }
                         break;
                 }
                 break;
             case 'portfolio':
                 //set portfolio breadcrumb navigation
                 if ($this->atts['set_breadcrumb'] && is_page()) {
                     $_SESSION["avia_{$entry->post_type}"] = get_the_ID();
                 }
                 //check if the user has set up a custom link
                 if (!post_password_required($id)) {
                     $custom_link = get_post_meta($id, '_portfolio_custom_link', true) != "" ? get_post_meta($id, '_portfolio_custom_link_url', true) : false;
                     if ($custom_link) {
                         $this->loop[$key]['url'] = $custom_link;
                     }
                 }
                 break;
             case 'attachment':
                 $custom_url = get_post_meta($id, 'av-custom-link', true);
                 $this->loop[$key]['thumb_ID'] = $id;
                 $this->loop[$key]['content'] = $entry->post_excerpt;
                 if ($custom_url) {
                     $this->loop[$key]['url'] = $custom_url;
                 } else {
                     $this->loop[$key]['url'] = wp_get_attachment_image_src($id, apply_filters('avf_avia_builder_masonry_lightbox_img_size', 'large'));
                     $this->loop[$key]['url'] = reset($this->loop[$key]['url']);
                 }
                 break;
             case 'product':
                 //check if woocommerce is enabled in the first place so we can use woocommerce functions
                 if (function_exists('avia_woocommerce_enabled') && avia_woocommerce_enabled()) {
                     $tagTax = "product_tag";
                     $product = get_product($id);
                     $overlay_img = avia_woocommerce_gallery_first_thumbnail($id, $img_size, true);
                     $this->loop[$key]['text_after'] .= '<span class="av-masonry-price price">' . $product->get_price_html() . "</span>";
                     if ($product->is_on_sale()) {
                         $this->loop[$key]['text_after'] .= '<span class="onsale">' . __('Sale!', 'avia_framework') . '</span>';
                     }
                 }
                 break;
         }
         //check if post is password protected
         if (post_password_required($id)) {
             $this->loop[$key]['content'] = "";
             $this->loop[$key]['class'][] = "entry-protected";
             $this->loop[$key]['thumb_ID'] = "";
             $this->loop[$key]['text_before'] = av_icon_display('closed');
             $this->loop[$key]['text_after'] = $this->loop[$key]['date'];
         }
         //set the html tags. depending on the link settings use either an a tag or a div tag
         if (!empty($this->atts['container_links']) || !empty($custom_url)) {
             $this->loop[$key]['html_tags'] = array('a href="' . $this->loop[$key]['url'] . '"', 'a');
             //opening and closing tag for the masonry container
         } else {
             $this->loop[$key]['html_tags'] = array('div', 'div');
         }
         //get post tags
         $this->loop[$key]['tags'] = wp_get_post_terms($id, $tagTax, array('fields' => 'slugs'));
         //check if the image got landscape as well as portrait class applied. in that case use a bigger image size
         if (strlen($this->ratio_check_by_tag($this->loop[$key]['tags'])) > 20) {
             $img_size = 'extra_large';
         }
         //get attachment data
         $this->loop[$key]['attachment'] = !empty($this->loop[$key]['thumb_ID']) ? wp_get_attachment_image_src($this->loop[$key]['thumb_ID'], $img_size) : "";
         //get overlay attachment in case the overlay is set
         $this->loop[$key]['attachment_overlay'] = !empty($overlay_img) ? wp_get_attachment_image_src($overlay_img, $img_size) : "";
         //apply filter for other post types, in case we want to use them and display additional/different information
         $this->loop[$key] = apply_filters('avf_masonry_loop_prepare', $this->loop[$key], $this->entries);
     }
 }