/**
 * Render Download Columns
 *
 * @since 1.0
 * @param string $column_name Column name
 * @param int $post_id Download (Post) ID
 * @return void
 */
function edd_render_download_columns($column_name, $post_id)
{
    if (get_post_type($post_id) == 'download') {
        global $edd_options;
        $style = isset($edd_options['button_style']) ? $edd_options['button_style'] : 'button';
        $color = isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : 'blue';
        $purchase_text = !empty($edd_options['add_to_cart_text']) ? $edd_options['add_to_cart_text'] : __('Purchase', 'edd');
        switch ($column_name) {
            case 'download_category':
                echo get_the_term_list($post_id, 'download_category', '', ', ', '');
                break;
            case 'download_tag':
                echo get_the_term_list($post_id, 'download_tag', '', ', ', '');
                break;
            case 'price':
                if (edd_has_variable_prices($post_id)) {
                    echo edd_price_range($post_id);
                } else {
                    echo edd_price($post_id, false);
                    echo '<input type="hidden" class="downloadprice-' . $post_id . '" value="' . edd_get_download_price($post_id) . '" />';
                }
                break;
            case 'sales':
                echo edd_get_download_sales_stats($post_id);
                break;
            case 'earnings':
                echo edd_currency_filter(edd_format_amount(edd_get_download_earnings_stats($post_id)));
                break;
            case 'shortcode':
                echo '[purchase_link id="' . absint($post_id) . '" text="' . esc_html($purchase_text) . '" style="' . $style . '" color="' . esc_attr($color) . '"]';
                break;
        }
    }
}
/**
 * Render Download Columns
 *
 * @since 1.0
 * @param string $column_name Column name
 * @param int $post_id Download (Post) ID
 * @return void
 */
function edd_render_download_columns($column_name, $post_id)
{
    if (get_post_type($post_id) == 'download') {
        global $edd_options;
        $style = isset($edd_options['button_style']) ? $edd_options['button_style'] : 'button';
        $color = isset($edd_options['checkout_color']) ? $edd_options['checkout_color'] : 'blue';
        $color = $color == 'inherit' ? '' : $color;
        $purchase_text = !empty($edd_options['add_to_cart_text']) ? $edd_options['add_to_cart_text'] : __('Purchase', 'edd');
        switch ($column_name) {
            case 'download_category':
                echo get_the_term_list($post_id, 'download_category', '', ', ', '');
                break;
            case 'download_tag':
                echo get_the_term_list($post_id, 'download_tag', '', ', ', '');
                break;
            case 'price':
                if (edd_has_variable_prices($post_id)) {
                    echo edd_price_range($post_id);
                } else {
                    echo edd_price($post_id, false);
                    echo '<input type="hidden" class="downloadprice-' . $post_id . '" value="' . edd_get_download_price($post_id) . '" />';
                }
                break;
            case 'sales':
                if (current_user_can('view_product_stats', $post_id)) {
                    echo '<a href="' . esc_url(admin_url('edit.php?post_type=download&page=edd-reports&tab=logs&view=sales&download=' . $post_id)) . '">';
                    echo edd_get_download_sales_stats($post_id);
                    echo '</a>';
                } else {
                    echo '-';
                }
                break;
            case 'earnings':
                if (current_user_can('view_product_stats', $post_id)) {
                    echo '<a href="' . esc_url(admin_url('edit.php?post_type=download&page=edd-reports&view=downloads&download-id=' . $post_id)) . '">';
                    echo edd_currency_filter(edd_format_amount(edd_get_download_earnings_stats($post_id)));
                    echo '</a>';
                } else {
                    echo '-';
                }
                break;
            case 'shortcode':
                echo '[purchase_link id="' . absint($post_id) . '" text="' . esc_html($purchase_text) . '" style="' . $style . '" color="' . esc_attr($color) . '"]';
                break;
        }
    }
}
/**
 * Render Download Columns
 *
 * @since 1.0
 * @param string $column_name Column name
 * @param int $post_id Download (Post) ID
 * @return void
 */
function edd_render_download_columns($column_name, $post_id)
{
    if (get_post_type($post_id) == 'download') {
        switch ($column_name) {
            case 'download_category':
                echo get_the_term_list($post_id, 'download_category', '', ', ', '');
                break;
            case 'download_tag':
                echo get_the_term_list($post_id, 'download_tag', '', ', ', '');
                break;
            case 'price':
                if (edd_has_variable_prices($post_id)) {
                    echo edd_price_range($post_id);
                } else {
                    echo edd_price($post_id, false);
                    echo '<input type="hidden" class="downloadprice-' . $post_id . '" value="' . edd_get_download_price($post_id) . '" />';
                }
                break;
            case 'sales':
                if (current_user_can('view_product_stats', $post_id)) {
                    echo '<a href="' . esc_url(admin_url('edit.php?post_type=download&page=edd-reports&tab=logs&view=sales&download=' . $post_id)) . '">';
                    echo edd_get_download_sales_stats($post_id);
                    echo '</a>';
                } else {
                    echo '-';
                }
                break;
            case 'earnings':
                if (current_user_can('view_product_stats', $post_id)) {
                    echo '<a href="' . esc_url(admin_url('edit.php?post_type=download&page=edd-reports&view=downloads&download-id=' . $post_id)) . '">';
                    echo edd_currency_filter(edd_format_amount(edd_get_download_earnings_stats($post_id)));
                    echo '</a>';
                } else {
                    echo '-';
                }
                break;
        }
    }
}
Ejemplo n.º 4
0
 public function product_list_price($product_id)
 {
     if (edd_has_variable_prices($product_id)) {
         $price = edd_price_range($product_id);
     } else {
         $price = edd_price($product_id);
     }
     $price = apply_filters('fes_product_list_price', $price, $product_id);
     return $price;
 }
Ejemplo n.º 5
0
    echo esc_url(reset($preview));
    ?>
" class="item-download pull-right">
                <i class="icon-arrow-down text-white"></i>
              </a>
              <?php 
}
?>
              <?php 
if (show_purchase($post->ID)) {
    ?>
              <div class="inline">
                <?php 
    $text = '';
    if (edd_has_variable_prices($post->ID)) {
        $text = edd_price_range($post->ID);
    }
    echo edd_get_purchase_link(array('download_id' => $post->ID, 'style' => 'btn btn-xs ' . get_theme_mod('btn-bg-color'), 'text' => $text));
    ?>
              </div>
              <?php 
}
?>
            </div>
        </div>

        <a href="<?php 
the_permalink();
?>
" data-pjax title="<?php 
the_title_attribute();
 /**
  * Widget
  *
  * @return   void
  * @since    1.0
  */
 function widget($args, $instance)
 {
     // get the title and apply filters
     $title = apply_filters('widget_title', $instance['title'] ? $instance['title'] : '');
     // get show price boolean
     $show_price = isset($instance['show_price']) && $instance['show_price'] === 1 ? 1 : 0;
     // get the thumbnail boolean
     $thumbnail = isset($instance['thumbnail']) && $instance['thumbnail'] === 1 ? 1 : 0;
     // set the thumbnail size
     $thumbnail_size = isset($instance['thumbnail_size']) ? $instance['thumbnail_size'] : 80;
     // start collecting the output
     $out = "";
     // check if there is a title
     if ($title) {
         // add the title to the ouput
         $out .= $args['before_title'] . $title . $args['after_title'];
     }
     // set the params
     $params = array('post_type' => 'download', 'posts_per_page' => 1, 'post_status' => 'publish', 'orderby' => 'rand');
     // get the random download
     $random_download = get_posts($params);
     // check download
     if (is_null($random_download) || empty($random_download)) {
         // return if there is no download
         return;
     } else {
         // start the list output
         $out .= "<ul class=\"widget-random-download\">\n";
         // set the link structure
         $link = "<a href=\"%s\" title=\"%s\" class=\"%s\" rel=\"bookmark\">%s</a>\n";
         // filter the thumbnail size
         $thumbnail_size = apply_filters('edd_widgets_random_download_thumbnail_size', array($thumbnail_size, $thumbnail_size));
         // loop trough the random download
         foreach ($random_download as $download) {
             // get the title
             $title = apply_filters('the_title', $download->post_title, $download->ID);
             $title_attr = apply_filters('the_title_attribute', $download->post_title, $download->ID);
             // get the post thumbnail
             if ($thumbnail === 1 && function_exists('has_post_thumbnail') && has_post_thumbnail($download->ID)) {
                 $post_thumbnail = get_the_post_thumbnail($download->ID, $thumbnail_size, array('title' => esc_attr($title_attr))) . "\n";
                 $out .= "<li class=\"widget-download-with-thumbnail\">\n";
                 $out .= sprintf($link, get_permalink($download->ID), esc_attr($title_attr), 'widget-download-thumb', $post_thumbnail);
             } else {
                 $out .= "<li>\n";
             }
             // append the download's title
             $out .= sprintf($link, get_permalink($download->ID), esc_attr($title_attr), 'widget-download-title', $title);
             // get the price
             if ($show_price === 1) {
                 if (edd_has_variable_prices($download->ID)) {
                     $price = edd_price_range($download->ID);
                 } else {
                     $price = edd_currency_filter(edd_get_download_price($download->ID));
                 }
                 $out .= sprintf("<span class=\"widget-download-price\">%s</span>\n", $price);
             }
             // finish this element
             $out .= "</li>\n";
         }
         // finish the list
         $out .= "</ul>\n";
     }
     // set the widget's containers
     echo $args['before_widget'] . $out . $args['after_widget'];
 }
            ?>
									</a>
									<?php 
        }
        ?>
								</div>

								<div class="edd-download-info">
									<?php 
        the_title('<h3 class="entry-title edd-download-title" itemprop="name"><a href="' . esc_url(get_permalink()) . '" itemprop="url">', '</a></h3>');
        ?>
									<p class="edd-download-price" itemprop="price"><?php 
        if (!edd_has_variable_prices(get_the_ID())) {
            edd_price(get_the_ID());
        } else {
            echo edd_price_range(get_the_ID());
        }
        ?>
</p>
								</div>
							</div>

						</div>

					</article>

					<?php 
    }
    ?>

				</div>
/**
 * Adds Download product price to oembed display
 *
 * @since 2.6
 * @return void
 */
function edd_add_oembed_price()
{
    if ('download' !== get_post_type(get_the_ID())) {
        return;
    }
    $show = !get_post_meta(get_the_ID(), '_edd_hide_purchase_link', true);
    if (apply_filters('edd_show_oembed_purchase_links', $show)) {
        echo '<style>.wp-embed-edd-price { margin: 20px 0 0 0; }</style>';
        echo '<div class="wp-embed-edd-price">';
        if (edd_has_variable_prices(get_the_ID())) {
            echo edd_price_range(get_the_ID());
        } else {
            edd_price(get_the_ID(), true);
        }
        echo '</div>';
    }
}
 /**
  * Widget
  *
  * @return   void
  * @since    1.0
  */
 function widget($args, $instance)
 {
     global $post;
     if (!is_singular('download')) {
         return;
     }
     // get the title and apply filters
     $title = apply_filters('widget_title', $instance['title'] ? $instance['title'] : '');
     // set the limit
     $limit = isset($instance['limit']) ? $instance['limit'] : 4;
     // get show price boolean
     $show_price = isset($instance['show_price']) && $instance['show_price'] === 1 ? 1 : 0;
     // get the thumbnail boolean
     $thumbnail = isset($instance['thumbnail']) && $instance['thumbnail'] === 1 ? 1 : 0;
     // set the thumbnail size
     $thumbnail_size = isset($instance['thumbnail_size']) ? $instance['thumbnail_size'] : 80;
     // start collecting the output
     $out = "";
     // check if there is a title
     if ($title) {
         // add the title to the ouput
         $out .= $args['before_title'] . $title . $args['after_title'];
     }
     // verify there is a post
     if (!isset($post->post_type) || $post->post_type != 'download') {
         return;
     }
     // initialize 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;
     // loop and get related posts
     while (count($related_downloads) < $limit && 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' => $limit, '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) == $limit) {
                         break;
                     }
                     $related_downloads[$related_download->ID] = $related_download;
                 }
             }
         }
         $c = $c + 1;
         // limit to 5 loops
         if ($c > 5) {
             break;
         }
     }
     // return empty if there are no related downloads
     if (empty($related_downloads)) {
         return;
     }
     // get the post type
     $post_type_obj = get_post_type_object($post_type);
     // start the list output
     $out .= "<ul class=\"widget-related-entries\">\n";
     // set the link structure
     $link = "<a href=\"%s\" title=\"%s\" class=\"%s\" rel=\"bookmark\">%s</a>\n";
     // filter the thumbnail size
     $thumbnail_size = apply_filters('edd_widgets_related_downloads_thumbnail_size', array($thumbnail_size, $thumbnail_size));
     // loop trough all downloads
     foreach ($related_downloads as $download) {
         // get the title
         $title = apply_filters('the_title', $download->post_title, $download->ID);
         $title_attr = apply_filters('the_title_attribute', $download->post_title, $download->ID);
         // get the post thumbnail
         if ($thumbnail === 1 && function_exists('has_post_thumbnail') && has_post_thumbnail($download->ID)) {
             $post_thumbnail = get_the_post_thumbnail($download->ID, $thumbnail_size, array('title' => esc_attr($title_attr))) . "\n";
             $out .= "<li class=\"widget-download-with-thumbnail\">\n";
             $out .= sprintf($link, get_permalink($download->ID), esc_attr($title_attr), 'widget-download-thumb', $post_thumbnail);
         } else {
             $out .= "<li>\n";
         }
         // append the download's title
         $out .= sprintf($link, get_permalink($download->ID), esc_attr($title_attr), 'widget-download-title', $title);
         // get the price
         if ($show_price === 1) {
             if (edd_has_variable_prices($download->ID)) {
                 $price = edd_price_range($download->ID);
             } else {
                 $price = edd_currency_filter(edd_get_download_price($download->ID));
             }
             $out .= sprintf("<span class=\"widget-download-price\">%s</span>\n", $price);
         }
         // finish this element
         $out .= "</li>\n";
     }
     // finish the list
     $out .= "</ul>\n";
     echo $args['before_widget'] . $out . $args['after_widget'];
 }
 /**
  * Widget
  *
  * @return   void
  * @since    1.0
  */
 function widget($args, $instance)
 {
     if (false == ($cache = get_transient('edd_widgets_most_recent'))) {
         // get the title and apply filters
         $title = apply_filters('widget_title', $instance['title'] ? $instance['title'] : '');
         // get the offset
         $offset = $instance['offset'] ? $instance['offset'] : 0;
         // set the limit
         $limit = isset($instance['limit']) ? $instance['limit'] : 4;
         // get show price boolean
         $show_price = isset($instance['show_price']) && $instance['show_price'] === 1 ? 1 : 0;
         // get the thumbnail boolean
         $thumbnail = isset($instance['thumbnail']) && $instance['thumbnail'] === 1 ? 1 : 0;
         // set the thumbnail size
         $thumbnail_size = isset($instance['thumbnail_size']) ? $instance['thumbnail_size'] : 80;
         // get the category
         $category = isset($instance['category']) ? $instance['category'] : 'edd-all-categories';
         // start collecting the output
         $out = "";
         // check if there is a title
         if ($title) {
             // add the title to the ouput
             $out .= $args['before_title'] . $title . $args['after_title'];
         }
         // set the params
         $params = array('post_type' => 'download', 'posts_per_page' => $limit, 'post_status' => 'publish', 'orderby' => 'date', 'offset' => $offset);
         // adjust params if we're only pulling one category
         if (isset($category) && $category != 'edd-all-categories') {
             $params['tax_query'][] = array('taxonomy' => 'download_category', 'field' => 'slug', 'terms' => $category);
         }
         // get the most recent downloads
         $most_recent = get_posts($params);
         // check the downloads
         if (is_null($most_recent) || empty($most_recent)) {
             // return if there are no downloads
             return;
         } else {
             // start the list output
             $out .= "<ul class=\"widget-most-recent\">\n";
             // set the link structure
             $link = "<a href=\"%s\" title=\"%s\" class=\"%s\" rel=\"bookmark\">%s</a>\n";
             // filter the thumbnail size
             $thumbnail_size = apply_filters('edd_widgets_most_recent_thumbnail_size', array($thumbnail_size, $thumbnail_size));
             // loop trough all downloads
             foreach ($most_recent as $download) {
                 // get the title
                 $title = apply_filters('the_title', $download->post_title, $download->ID);
                 $title_attr = apply_filters('the_title_attribute', $download->post_title, $download->ID);
                 // get the post thumbnail
                 if ($thumbnail === 1 && function_exists('has_post_thumbnail') && has_post_thumbnail($download->ID)) {
                     $post_thumbnail = get_the_post_thumbnail($download->ID, $thumbnail_size, array('title' => esc_attr($title_attr))) . "\n";
                     $out .= "<li class=\"widget-download-with-thumbnail\">\n";
                     $out .= sprintf($link, get_permalink($download->ID), esc_attr($title_attr), 'widget-download-thumb', $post_thumbnail);
                 } else {
                     $out .= "<li>\n";
                 }
                 // append the download's title
                 $out .= sprintf($link, get_permalink($download->ID), esc_attr($title_attr), 'widget-download-title', $title);
                 // get the price
                 if ($show_price === 1) {
                     if (edd_has_variable_prices($download->ID)) {
                         $price = edd_price_range($download->ID);
                     } else {
                         $price = edd_currency_filter(edd_get_download_price($download->ID));
                     }
                     $out .= sprintf("<span class=\"widget-download-price\">%s</span>\n", $price);
                 }
                 // finish this element
                 $out .= "</li>\n";
             }
             // finish the list
             $out .= "</ul>\n";
         }
         // set the widget's containers
         $cache = $args['before_widget'] . $out . $args['after_widget'];
         // store the result on a temporal transient
         set_transient('edd_widgets_most_recent', $cache);
     }
     echo $cache;
 }
 /**
  * Widget
  *
  * @return   void
  * @since    1.0
  */
 function widget($args, $instance)
 {
     if (false == ($cache = get_transient('edd_widgets_top_sellers'))) {
         // get the title and apply filters
         $title = apply_filters('widget_title', $instance['title'] ? $instance['title'] : '');
         // set the limit
         $limit = isset($instance['limit']) ? $instance['limit'] : 4;
         // get show price boolean
         $show_price = isset($instance['show_price']) && $instance['show_price'] === 1 ? 1 : 0;
         // get the thumbnail boolean
         $thumbnail = isset($instance['thumbnail']) && $instance['thumbnail'] === 1 ? 1 : 0;
         // set the thumbnail size
         $thumbnail_size = isset($instance['thumbnail_size']) ? $instance['thumbnail_size'] : 80;
         // start collecting the output
         $out = "";
         // check if there is a title
         if ($title) {
             // add the title to the ouput
             $out .= $args['before_title'] . $title . $args['after_title'];
         }
         // set the params
         $params = array('post_type' => 'download', 'posts_per_page' => $limit, 'post_status' => 'publish', 'meta_key' => '_edd_download_sales', 'meta_compare' => '>', 'meta_value' => 0, 'orderby' => 'meta_value_num');
         // get top sellers
         $top_sellers = get_posts($params);
         // check top sellers
         if (is_null($top_sellers) || empty($top_sellers)) {
             // return if there are no top sellers
             return;
         } else {
             // start the list output
             $out .= "<ul class=\"widget-top-sellers\">\n";
             // set the link structure
             $link = "<a href=\"%s\" title=\"%s\" class=\"%s\" rel=\"bookmark\">%s</a>\n";
             // filter the thumbnail size
             $thumbnail_size = apply_filters('edd_widgets_top_sellers_thumbnail_size', array($thumbnail_size, $thumbnail_size));
             // loop trough all downloads
             foreach ($top_sellers as $download) {
                 // get the title
                 $title = apply_filters('the_title', $download->post_title, $download->ID);
                 $title_attr = apply_filters('the_title_attribute', $download->post_title, $download->ID);
                 // get the post thumbnail
                 if ($thumbnail === 1 && function_exists('has_post_thumbnail') && has_post_thumbnail($download->ID)) {
                     $post_thumbnail = get_the_post_thumbnail($download->ID, $thumbnail_size, array('title' => esc_attr($title_attr))) . "\n";
                     $out .= "<li class=\"widget-download-with-thumbnail\">\n";
                     $out .= sprintf($link, get_permalink($download->ID), esc_attr($title_attr), 'widget-download-thumb', $post_thumbnail);
                 } else {
                     $out .= "<li>\n";
                 }
                 // append the download's title
                 $out .= sprintf($link, get_permalink($download->ID), esc_attr($title_attr), 'widget-download-title', $title);
                 // get the price
                 if ($show_price === 1) {
                     if (edd_has_variable_prices($download->ID)) {
                         $price = edd_price_range($download->ID);
                     } else {
                         $price = edd_currency_filter(edd_get_download_price($download->ID));
                     }
                     $out .= sprintf("<span class=\"widget-download-price\">%s</span>\n", $price);
                 }
                 // finish this element
                 $out .= "</li>\n";
             }
             // finish the list
             $out .= "</ul>\n";
         }
         // set the widget's containers
         $cache = $args['before_widget'] . $out . $args['after_widget'];
         // store the result on a temporal transient
         set_transient('edd_widgets_top_sellers', $cache);
     }
     echo $cache;
 }
Ejemplo n.º 12
0
				<div id="secondary">
					<div id="sticker">
						<div id="purchase-box" class="purchase-box">
							<?php 
do_action('checkout_above_purchase_sidebar');
?>

							<div class="download-price download-aside">
								<?php 
if (edd_has_variable_prices($download_id)) {
    ?>
									<!-- Get the price range -->
									<div class="purchase-price price-range">
										<?php 
    echo edd_price_range($download_id);
    ?>
									</div>
								<?php 
} else {
    if (function_exists('edd_cp_has_custom_pricing') && edd_cp_has_custom_pricing($download_id)) {
        ?>
									<div class="purchase-price name-price">
										<?php 
        _e('Name your price:', 'checkout');
        ?>
									</div>
								<?php 
    } else {
        if (edd_is_free_download($download_id)) {
            ?>