</a>
                </h3><!-- .entry-title -->
            </header><!-- .entry-header -->

            <div class="entry-meta">
                <?php 
if (!edd_item_in_cart($post->ID)) {
    if (edd_has_variable_prices($post->ID)) {
        echo '<a href="' . get_permalink() . '" class="button edd_button">' . __('View Details', 'edd-digitalstore') . '</a>';
    } else {
        echo do_shortcode('[purchase_link id="' . $post->ID . '" price="0" text="' . __('Add To Cart', 'edd-digitalstore') . '" style="blue"]');
    }
} else {
    echo '<a href="' . get_permalink($edd_options['purchase_page']) . '" class="edd_go_to_checkout edd_button">' . __('Checkout', 'edd-digitalstore') . '</a>';
}
?>
                <span class="entry-price"><?php 
echo digitalstore_edd_the_price($post->ID);
?>
</span>
            </div><!-- .entry-meta -->

        </div><!-- .entry -->

</article><!-- #post-<?php 
the_ID();
?>
 -->

<?php 
do_action('digitalstore_after_content', $post);
Example #2
0
 function digitalstore_related_entries_callback($post)
 {
     if (!is_singular('download')) {
         return;
     }
     // verify there is a post
     if (!isset($post)) {
         return;
     }
     // initalize array
     $related_downloads = array();
     // get the post taxonomies
     $taxonomies = get_object_taxonomies($post, 'objects');
     // verify there is a taxonomy
     if (empty($taxonomies)) {
         return;
     }
     // loop and get terms
     $terms_in = array();
     $i = 0;
     foreach ($taxonomies as $taxonomy) {
         $terms = get_the_terms($post->ID, $taxonomy->name);
         $terms_in[$i]['tax'] = $taxonomy->name;
         if (!empty($terms)) {
             foreach ($terms as $term) {
                 $terms_in[$i]['terms'][] = $term->term_id;
             }
         }
         $i++;
     }
     $post_id = $post->ID;
     $post_type = $post->post_type;
     $c = 0;
     while (count($related_downloads) < 4 && isset($terms_in[$c])) {
         // check for tax and terms
         if (!isset($terms_in[$c]['tax']) || !isset($terms_in[$c]['terms'])) {
             $c = $c + 1;
             continue;
         }
         // loop with a max of 4 posts per query
         foreach ($terms_in[$c]['terms'] as $key => $value) {
             $params = array('tax_query' => array(array('taxonomy' => $terms_in[$c]['tax'], 'field' => 'id', 'terms' => $value)), 'post_type' => $post_type, 'post__not_in' => array($post_id), 'numberposts' => 4, 'ignore_sticky_posts' => 1, 'post_status' => 'publish', 'orderby' => 'rand');
             $related = get_posts($params);
             if (!empty($related)) {
                 foreach ($related as $related_download) {
                     if (count($related_downloads) == 4) {
                         break;
                     }
                     $related_downloads[$related_download->ID] = $related_download;
                 }
             }
         }
         $c = $c + 1;
         // limit to 5 loops
         if ($c > 5) {
             break;
         }
     }
     if (empty($related_downloads)) {
         return;
     }
     $post_type_obj = get_post_type_object($post_type);
     $out = '<h3 class="section-title related-entries-title">' . sprintf(__('Related %s', 'edd-digitalstore'), $post_type_obj->labels->menu_name) . '</h3>';
     $out .= '<ul class="related-entries">';
     $link = '<a href="%s" title="%s" rel="bookmark" class="%s">%s</a>';
     foreach ($related_downloads as $download) {
         $permalink = get_permalink($download->ID);
         $price = '<div class="edd-the-price">' . digitalstore_edd_the_price($download->ID) . '</div>';
         $thumb = "";
         $out .= '<li>';
         if (has_post_thumbnail($download->ID)) {
             $thumb = sprintf($link, $permalink, $download->post_title, 'related-entry-thumb', get_the_post_thumbnail($download->ID, 'digitalstore_thumb_small', array('title' => $download->post_title)) . $price);
         } else {
             $thumb = sprintf($link, $permalink, $download->post_title, 'related-entry-thumb', '<img src="' . get_stylesheet_directory_uri() . '/img/nopic.gif" alt="' . $download->post_title . '"/>' . $price);
         }
         $out .= $thumb;
         $out .= sprintf($link, $permalink, $download->post_title, 'related-entry-title', $download->post_title);
         $out .= '</li>';
     }
     $out .= '</ul>';
     wp_reset_query();
     echo $out;
 }
Example #3
0
    function digitalstore_latest_downloads($args = array())
    {
        // parse attributes
        $atts = wp_parse_args($args, array('title' => __('Latest %s', 'edd-digitalstore'), 'all' => 1, 'limit' => get_option('posts_per_page'), 'thumb' => 1, 'size' => 'digitalstore_thumb_small', 'fallback' => get_stylesheet_directory_uri() . '/img/nopic.gif'));
        // filter atts
        $atts = apply_filters('digitalstore_latest_downloads_atts', $atts);
        // get post type object
        $post_type_obj = get_post_type_object('download');
        // check if it's valid
        if (is_null($post_type_obj)) {
            return;
        }
        // set query arguments
        $params = array('post_type' => 'download', 'post_status' => 'publish', 'posts_per_page' => $atts['limit']);
        // create query
        $downloads = new WP_Query($params);
        // loop
        if ($downloads->have_posts()) {
            $i = 1;
            ?>
        <div class="section-latest latest-<?php 
            echo strtolower($post_type_obj->label);
            ?>
">
            <div class="section-title">
                <h3 class="latest-title"><?php 
            printf($atts['title'], $post_type_obj->labels->menu_name);
            ?>
</h3>
                <?php 
            if ($atts['all'] == 1) {
                ?>
                    <a href="<?php 
                echo get_post_type_archive_link('download');
                ?>
" class="view-all" ><span><?php 
                _e('View All', 'edd-digitalstore');
                ?>
</span></a><!-- .view-all -->
                <?php 
            }
            ?>
            </div><!-- .section-title -->
            <ul class="latest-listing">
            <?php 
            while ($downloads->have_posts()) {
                $downloads->the_post();
                ?>
                <li<?php 
                if ($i % 4 == 0) {
                    echo ' class="last"';
                }
                ?>
>
                    <a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
" class="latest-thumbnail">
                    <div class="edd-the-price">
                        <?php 
                echo digitalstore_edd_the_price(get_the_ID());
                ?>
                    </div>
                    <?php 
                if (has_post_thumbnail() && $atts['thumb'] == 1) {
                    ?>
                        <?php 
                    the_post_thumbnail($atts['size']);
                    ?>
                    <?php 
                } elseif ($atts['fallback'] != "") {
                    ?>
                        <img src="<?php 
                    echo $atts['fallback'];
                    ?>
" alt="<?php 
                    the_title();
                    ?>
" title="<?php 
                    the_title();
                    ?>
"/>
                    <?php 
                }
                ?>
                    </a><!-- latest-thumbnail -->

                    <div class="latest-meta">
                        <h5><a href="<?php 
                the_permalink();
                ?>
" title="<?php 
                the_title();
                ?>
"><?php 
                the_title();
                ?>
</a></h5>
                    </div><!-- latest-meta -->

                </li>
            <?php 
                $i++;
            }
            ?>
            </ul><!-- .latest-listing -->
        </div><!-- .section-latest-->
        <?php 
        }
        wp_reset_query();
        wp_reset_postdata();
    }