本文整理汇总了PHP中edd_get_download_earnings_stats函数的典型用法代码示例。如果您正苦于以下问题:PHP edd_get_download_earnings_stats函数的具体用法?PHP edd_get_download_earnings_stats怎么用?PHP edd_get_download_earnings_stats使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了edd_get_download_earnings_stats函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edd_render_download_columns
/**
* Render Donwload Columns
*
* Render the custom columns content.
*
* @access private
* @since 1.0
* @return void
*/
function edd_render_download_columns($column_name, $post_id)
{
if (get_post_type($post_id) == 'download') {
$sales = edd_get_download_sales_stats($post_id);
$earnings = edd_get_download_earnings_stats($post_id);
$color = get_post_meta($post_id, '_edd_purchase_color', true);
$color = $color ? $color : 'blue';
$purchase_text = get_post_meta($post_id, '_edd_purchase_text', true);
$purchase_text = $purchase_text && '' !== $purchase_text ? $purchase_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':
echo edd_price($post_id, false);
if (!edd_has_variable_prices($post_id)) {
echo '<input type="hidden" class="downloadprice-' . $post_id . '" value="' . edd_get_download_price($post_id) . '" />';
}
break;
case 'sales':
echo $sales;
break;
case 'earnings':
echo edd_currency_filter($earnings);
break;
case 'shortcode':
echo '[purchase_link id="' . absint($post_id) . '" text="' . esc_html($purchase_text) . '" style="button" color="' . esc_attr($color) . '"]';
break;
}
}
}
示例2: edd_render_download_columns
/**
* 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;
}
}
}
示例3: edd_render_download_columns
/**
* 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;
}
}
}
示例4: edd_render_download_columns
/**
* 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;
}
}
}
示例5: edd_show_download_earnings_graph
/**
* Show Download Earnings Graph
*
* @access public
* @since 1.0
* @return void
*/
function edd_show_download_earnings_graph($bgcolor = 'white')
{
$downloads = get_posts(array('post_type' => 'download', 'posts_per_page' => -1));
if ($downloads) {
ob_start();
?>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
// earnings chart
google.setOnLoadCallback(drawEarningsChart);
function drawEarningsChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', '<?php
_e("Download", "edd");
?>
');
data.addColumn('number', '<?php
_e("Earnings", "edd");
?>
');
data.addRows([
<?php
foreach ($downloads as $download) {
?>
['<?php
echo html_entity_decode(get_the_title($download->ID), ENT_COMPAT, 'UTF-8');
?>
',
<?php
echo edd_get_download_earnings_stats($download->ID);
?>
],
<?php
}
?>
]);
var options = {
title: "<?php
echo sprintf(__('%s Performance in Earnings', 'edd'), edd_get_label_singular());
?>
",
colors:['#a3bcd3'],
fontSize: 12,
backgroundColor: '<?php
echo $bgcolor;
?>
'
};
var chart = new google.visualization.ColumnChart(document.getElementById('earnings_chart_div'));
chart.draw(data, options);
}
</script>
<div id="earnings_chart_div"></div>
<?php
echo ob_get_clean();
}
}
示例6: decrease_earnings
/**
* Decrease the earnings by the given amount
*
* @since 2.2
* @param integer $amount
* @return float|false
*/
public function decrease_earnings($amount)
{
$earnings = edd_get_download_earnings_stats($this->ID);
if ($earnings > 0) {
// Only decrease if greater than zero
$new_amount = $earnings - (double) $amount;
if ($this->update_meta('_edd_download_earnings', $new_amount)) {
$this->earnings = $new_amount;
return $this->earnings;
}
}
return false;
}
示例7: edd_generate_pdf
/**
* Generate PDF Reports
*
* Generates PDF report on sales and earnings for all downloads for the current year.
*
* @since 1.1.4.0
* @param string $data
* @uses edd_pdf
* @author Sunny Ratilal
*/
function edd_generate_pdf($data)
{
if (!current_user_can('view_shop_reports')) {
wp_die(__('You do not have permission to generate PDF sales reports', 'easy-digital-downloads'), __('Error', 'easy-digital-downloads'), array('response' => 403));
}
if (!wp_verify_nonce($_GET['_wpnonce'], 'edd_generate_pdf')) {
wp_die(__('Nonce verification failed', 'easy-digital-downloads'), __('Error', 'easy-digital-downloads'), array('response' => 403));
}
require_once EDD_PLUGIN_DIR . '/includes/libraries/fpdf/fpdf.php';
require_once EDD_PLUGIN_DIR . '/includes/libraries/fpdf/edd_pdf.php';
$daterange = date_i18n(get_option('date_format'), mktime(0, 0, 0, 1, 1, date('Y'))) . ' ' . utf8_decode(__('to', 'easy-digital-downloads')) . ' ' . date_i18n(get_option('date_format'));
$pdf = new edd_pdf();
$pdf->AddPage('L', 'A4');
$pdf->SetTitle(utf8_decode(__('Sales and earnings reports for the current year for all products', 'easy-digital-downloads')));
$pdf->SetAuthor(utf8_decode(__('Easy Digital Downloads', 'easy-digital-downloads')));
$pdf->SetCreator(utf8_decode(__('Easy Digital Downloads', 'easy-digital-downloads')));
$pdf->Image(EDD_PLUGIN_URL . 'assets/images/edd-logo-pdf.png', 205, 10);
$pdf->SetMargins(8, 8, 8);
$pdf->SetX(8);
$pdf->SetFont('Helvetica', '', 16);
$pdf->SetTextColor(50, 50, 50);
$pdf->Cell(0, 3, utf8_decode(__('Sales and earnings reports for the current year for all products', 'easy-digital-downloads')), 0, 2, 'L', false);
$pdf->SetFont('Helvetica', '', 13);
$pdf->Ln();
$pdf->SetTextColor(150, 150, 150);
$pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'easy-digital-downloads')) . $daterange, 0, 2, 'L', false);
$pdf->Ln();
$pdf->SetTextColor(50, 50, 50);
$pdf->SetFont('Helvetica', '', 14);
$pdf->Cell(0, 10, utf8_decode(__('Table View', 'easy-digital-downloads')), 0, 2, 'L', false);
$pdf->SetFont('Helvetica', '', 12);
$pdf->SetFillColor(238, 238, 238);
$pdf->Cell(70, 6, utf8_decode(__('Product Name', 'easy-digital-downloads')), 1, 0, 'L', true);
$pdf->Cell(30, 6, utf8_decode(__('Price', 'easy-digital-downloads')), 1, 0, 'L', true);
$category_labels = edd_get_taxonomy_labels('download_category');
$pdf->Cell(50, 6, utf8_decode($category_labels['name']), 1, 0, 'L', true);
$pdf->Cell(50, 6, utf8_decode(__('Tags', 'easy-digital-downloads')), 1, 0, 'L', true);
$pdf->Cell(45, 6, utf8_decode(__('Number of Sales', 'easy-digital-downloads')), 1, 0, 'L', true);
$pdf->Cell(35, 6, utf8_decode(__('Earnings to Date', 'easy-digital-downloads')), 1, 1, 'L', true);
$year = date('Y');
$downloads = get_posts(array('post_type' => 'download', 'year' => $year, 'posts_per_page' => -1));
if ($downloads) {
$pdf->SetWidths(array(70, 30, 50, 50, 45, 35));
foreach ($downloads as $download) {
$pdf->SetFillColor(255, 255, 255);
$title = utf8_decode(get_the_title($download->ID));
if (edd_has_variable_prices($download->ID)) {
$prices = edd_get_variable_prices($download->ID);
$first = $prices[0]['amount'];
$last = array_pop($prices);
$last = $last['amount'];
if ($first < $last) {
$min = $first;
$max = $last;
} else {
$min = $last;
$max = $first;
}
$price = html_entity_decode(edd_currency_filter(edd_format_amount($min)) . ' - ' . edd_currency_filter(edd_format_amount($max)));
} else {
$price = html_entity_decode(edd_currency_filter(edd_get_download_price($download->ID)));
}
$categories = get_the_term_list($download->ID, 'download_category', '', ', ', '');
$categories = $categories ? strip_tags($categories) : '';
$tags = get_the_term_list($download->ID, 'download_tag', '', ', ', '');
$tags = $tags ? strip_tags($tags) : '';
$sales = edd_get_download_sales_stats($download->ID);
$earnings = html_entity_decode(edd_currency_filter(edd_get_download_earnings_stats($download->ID)));
if (function_exists('iconv')) {
// Ensure characters like euro; are properly converted. See GithuB issue #472 and #1570
$price = iconv('UTF-8', 'windows-1252', utf8_encode($price));
$earnings = iconv('UTF-8', 'windows-1252', utf8_encode($earnings));
}
$pdf->Row(array($title, $price, $categories, $tags, $sales, $earnings));
}
} else {
$pdf->SetWidths(array(280));
$title = utf8_decode(sprintf(__('No %s found.', 'easy-digital-downloads'), edd_get_label_plural()));
$pdf->Row(array($title));
}
$pdf->Ln();
$pdf->SetTextColor(50, 50, 50);
$pdf->SetFont('Helvetica', '', 14);
$pdf->Cell(0, 10, utf8_decode(__('Graph View', 'easy-digital-downloads')), 0, 2, 'L', false);
$pdf->SetFont('Helvetica', '', 12);
$image = html_entity_decode(urldecode(edd_draw_chart_image()));
$image = str_replace(' ', '%20', $image);
$pdf->SetX(25);
$pdf->Image($image . '&file=.png');
$pdf->Ln(7);
//.........这里部分代码省略.........
示例8: edd_render_stats_meta_box
/**
* Render Stats Meta Box
*
* @since 1.0
* @global array $post Contains all the download data
* @return void
*/
function edd_render_stats_meta_box()
{
global $post;
if (!current_user_can('view_product_stats', $post->ID)) {
return;
}
$earnings = edd_get_download_earnings_stats($post->ID);
$sales = edd_get_download_sales_stats($post->ID);
?>
<p>
<strong class="label"><?php
_e('Sales:', 'edd');
?>
</strong>
<span><?php
echo $sales;
?>
— <a href="<?php
echo admin_url('/edit.php?page=edd-reports&view=sales&post_type=download&tab=logs&download=' . $post->ID);
?>
"><?php
_e('View Sales Log', 'edd');
?>
</a></span>
</p>
<p>
<strong class="label"><?php
_e('Earnings:', 'edd');
?>
</strong>
<span><?php
echo edd_currency_filter(edd_format_amount($earnings));
?>
</span>
</p>
<hr />
<p class="file-download-log">
<span><a href="<?php
echo admin_url('edit.php?page=edd-reports&view=file_downloads&post_type=download&tab=logs&download=' . $post->ID);
?>
"><?php
_e('View File Download Log', 'edd');
?>
</a></span><br/>
</p>
<p>
<span><a href="<?php
echo admin_url('edit.php?post_type=download&page=edd-reports&view=downloads&download-id=' . $post->ID);
?>
"><?php
_e('View Detailed Earnings Report', 'edd');
?>
</a></span>
</p>
<?php
do_action('edd_stats_meta_box');
}
示例9: edd_generate_pdf
/**
* Generate PDF Reports
*
* Generates PDF report on sales and earnings for all downloads for the current year.
*
* @since 1.1.4.0
* @param string $data
* @uses edd_pdf
* @author Sunny Ratilal
*/
function edd_generate_pdf($data)
{
$edd_pdf_reports_nonce = $_GET['_wpnonce'];
if (wp_verify_nonce($edd_pdf_reports_nonce, 'edd_generate_pdf')) {
require_once EDD_PLUGIN_DIR . '/includes/libraries/fpdf/fpdf.php';
require_once EDD_PLUGIN_DIR . '/includes/libraries/fpdf/edd_pdf.php';
$daterange = date_i18n(get_option('date_format'), mktime(0, 0, 0, 1, 1, date('Y'))) . ' ' . utf8_decode(__('to', 'edd')) . ' ' . date_i18n(get_option('date_format'));
$pdf = new edd_pdf();
$pdf->AddPage('L', 'A4');
$pdf->SetTitle(utf8_decode(__('Sales and earnings reports for the current year for all products', 'edd')));
$pdf->SetAuthor(utf8_decode(__('Easy Digital Downloads', 'edd')));
$pdf->SetCreator(utf8_decode(__('Easy Digital Downloads', 'edd')));
$pdf->Image(EDD_PLUGIN_URL . 'assets/images/edd-logo.png', 205, 10);
$pdf->SetMargins(8, 8, 8);
$pdf->SetX(8);
$pdf->SetFont('Helvetica', '', 16);
$pdf->SetTextColor(50, 50, 50);
$pdf->Cell(0, 3, utf8_decode(__('Sales and earnings reports for the current year for all products', 'edd')), 0, 2, 'L', false);
$pdf->SetFont('Helvetica', '', 13);
$pdf->Ln();
$pdf->SetTextColor(150, 150, 150);
$pdf->Cell(0, 6, utf8_decode(__('Date Range: ', 'edd')) . $daterange, 0, 2, 'L', false);
$pdf->Ln();
$pdf->SetTextColor(50, 50, 50);
$pdf->SetFont('Helvetica', '', 14);
$pdf->Cell(0, 10, utf8_decode(__('Table View', 'edd')), 0, 2, 'L', false);
$pdf->SetFont('Helvetica', '', 12);
$pdf->SetFillColor(238, 238, 238);
$pdf->Cell(70, 6, utf8_decode(__('Product Name', 'edd')), 1, 0, 'L', true);
$pdf->Cell(30, 6, utf8_decode(__('Price', 'edd')), 1, 0, 'L', true);
$pdf->Cell(50, 6, utf8_decode(__('Categories', 'edd')), 1, 0, 'L', true);
$pdf->Cell(50, 6, utf8_decode(__('Tags', 'edd')), 1, 0, 'L', true);
$pdf->Cell(45, 6, utf8_decode(__('Number of Sales', 'edd')), 1, 0, 'L', true);
$pdf->Cell(35, 6, utf8_decode(__('Earnings to Date', 'edd')), 1, 1, 'L', true);
$year = date('Y');
$downloads = get_posts(array('post_type' => 'download', 'year' => $year, 'posts_per_page' => -1));
if ($downloads) {
$pdf->SetWidths(array(70, 30, 50, 50, 45, 35));
foreach ($downloads as $download) {
$pdf->SetFillColor(255, 255, 255);
$title = utf8_decode(get_the_title($download->ID));
if (edd_has_variable_prices($download->ID)) {
$prices = edd_get_variable_prices($download->ID);
$first = $prices[0]['amount'];
$last = array_pop($prices);
$last = $last['amount'];
if ($first < $last) {
$min = $first;
$max = $last;
} else {
$min = $last;
$max = $first;
}
$price = html_entity_decode(edd_currency_filter(edd_format_amount($min)) . ' - ' . edd_currency_filter(edd_format_amount($max)));
} else {
$price = html_entity_decode(edd_currency_filter(edd_get_download_price($download->ID)));
}
$categories = get_the_term_list($download->ID, 'download_category', '', ', ', '');
$categories = $categories ? strip_tags($categories) : '';
$tags = get_the_term_list($download->ID, 'download_tag', '', ', ', '');
$tags = $tags ? strip_tags($tags) : '';
$sales = edd_get_download_sales_stats($download->ID);
$link = get_permalink($download->ID);
$earnings = html_entity_decode(edd_currency_filter(edd_get_download_earnings_stats($download->ID)));
$pdf->Row(array($title, $price, $categories, $tags, $sales, $earnings));
}
} else {
$pdf->SetWidths(array(280));
$title = utf8_decode(sprintf(__('No %s found.', 'edd'), edd_get_label_plural()));
$pdf->Row(array($title));
}
$pdf->Ln();
$pdf->SetTextColor(50, 50, 50);
$pdf->SetFont('Helvetica', '', 14);
$pdf->Cell(0, 10, utf8_decode(__('Graph View', 'edd')), 0, 2, 'L', false);
$pdf->SetFont('Helvetica', '', 12);
$image = html_entity_decode(urldecode(edd_draw_chart_image()));
$image = str_replace(' ', '%20', $image);
$pdf->SetX(25);
$pdf->Image($image . '&file=.png');
$pdf->Ln(7);
$pdf->Output('edd-report-' . date_i18n('Y-m-d') . '.pdf', 'D');
}
}
示例10: reports_data
/**
* Retrieve all report data for Downloads
*
* @access private
* @since 1.3
* @return array
*/
function reports_data()
{
$reports_data = array();
$orderby = isset($_GET['orderby']) ? $_GET['orderby'] : 'title';
$order = isset($_GET['order']) ? $_GET['order'] : 'DESC';
$report_args = array('post_type' => 'download', 'post_status' => 'publish', 'order' => $order, 'posts_per_page' => $this->per_page, 'paged' => $this->get_paged());
switch ($orderby) {
case 'title':
$report_args['orderby'] = 'title';
break;
case 'sales':
$report_args['orderby'] = 'meta_value_num';
$report_args['meta_key'] = '_edd_download_sales';
break;
case 'earnings':
$report_args['orderby'] = 'meta_value_num';
$report_args['meta_key'] = '_edd_download_earnings';
break;
}
$downloads = get_posts($report_args);
if ($downloads) {
foreach ($downloads as $download) {
$reports_data[] = array('ID' => $download->ID, 'title' => get_the_title($download->ID), 'sales' => edd_get_download_sales_stats($download->ID), 'earnings' => edd_get_download_earnings_stats($download->ID), 'average_sales' => edd_get_average_monthly_download_sales($download->ID), 'average_earnings' => edd_get_average_monthly_download_earnings($download->ID));
}
}
return $reports_data;
}
示例11: elseif
$html_content .= '</div>';
} elseif ($item_key == 'edd_sales_stats') {
$html_content .= '<div class="element element_' . $item_id . ' ' . $item_key . '" >';
$is_download = get_post_type(get_the_ID());
$active_plugins = get_option('active_plugins');
if (in_array('easy-digital-downloads/easy-digital-downloads.php', (array) $active_plugins) && $is_download == 'download') {
$sales_stats = edd_get_download_sales_stats(get_the_ID());
$html_content .= $sales_stats;
}
$html_content .= '</div>';
} elseif ($item_key == 'edd_earnings_stats') {
$html_content .= '<div class="element element_' . $item_id . ' ' . $item_key . '" >';
$is_download = get_post_type(get_the_ID());
$active_plugins = get_option('active_plugins');
if (in_array('easy-digital-downloads/easy-digital-downloads.php', (array) $active_plugins) && $is_download == 'download') {
$earnings_stats = edd_get_download_earnings_stats(get_the_ID());
$html_content .= $earnings_stats;
}
$html_content .= '</div>';
} elseif ($item_key == 'edd_add_to_cart') {
$html_content .= '<div class="element element_' . $item_id . ' ' . $item_key . '" >';
$is_download = get_post_type(get_the_ID());
$active_plugins = get_option('active_plugins');
if (in_array('easy-digital-downloads/easy-digital-downloads.php', (array) $active_plugins) && $is_download == 'download') {
$purchase_link = do_shortcode('[purchase_link id="' . get_the_ID() . '" text="' . __('Add to Cart', 'post_grid_textdomain') . '" style="button"]');
$html_content .= $purchase_link;
}
$html_content .= '</div>';
} elseif ($item_key == 'edd_categories') {
$html_content .= '<div class="element element_' . $item_id . ' ' . $item_key . '" >';
$is_download = get_post_type(get_the_ID());
示例12: reports_data
/**
* Build all the reports data
*
* @access public
* @since 2.4
* @return array $reports_data All the data for customer reports
*/
public function reports_data()
{
$cached_reports = get_transient('edd_earnings_by_category_data');
if (false !== $cached_reports) {
$reports_data = $cached_reports;
} else {
$reports_data = array();
$term_args = array('parent' => 0, 'hierarchical' => 0);
$categories = get_terms('download_category', $term_args);
foreach ($categories as $category_id => $category) {
$category_slugs = array($category->slug);
$child_args = array('parent' => $category->term_id, 'hierarchical' => 0);
$child_terms = get_terms('download_category', $child_args);
if (!empty($child_terms)) {
foreach ($child_terms as $child_term) {
$category_slugs[] = $child_term->slug;
}
}
$download_args = array('post_type' => 'download', 'posts_per_page' => -1, 'fields' => 'ids', 'tax_query' => array(array('taxonomy' => 'download_category', 'field' => 'slug', 'terms' => $category_slugs)));
$downloads = get_posts($download_args);
$sales = 0;
$earnings = 0.0;
$avg_sales = 0;
$avg_earnings = 0.0;
foreach ($downloads as $download) {
$sales += edd_get_download_sales_stats($download);
$earnings += edd_get_download_earnings_stats($download);
$avg_sales += edd_get_average_monthly_download_sales($download);
$avg_earnings += edd_get_average_monthly_download_earnings($download);
}
$avg_sales = round($avg_sales / count($downloads));
$avg_earnings = round($avg_earnings / count($downloads), edd_currency_decimal_filter());
$reports_data[] = array('ID' => $category->term_id, 'label' => $category->name, 'total_sales' => edd_format_amount($sales, false), 'total_sales_raw' => $sales, 'total_earnings' => edd_currency_filter(edd_format_amount($earnings)), 'total_earnings_raw' => $earnings, 'avg_sales' => edd_format_amount($avg_sales, false), 'avg_earnings' => edd_currency_filter(edd_format_amount($avg_earnings)), 'is_child' => false);
if (!empty($child_terms)) {
foreach ($child_terms as $child_term) {
$child_args = array('post_type' => 'download', 'posts_per_page' => -1, 'fields' => 'ids', 'tax_query' => array(array('taxonomy' => 'download_category', 'field' => 'slug', 'terms' => $child_term->slug)));
$child_downloads = get_posts($child_args);
$child_sales = 0;
$child_earnings = 0.0;
$child_avg_sales = 0;
$child_avg_earnings = 0.0;
foreach ($child_downloads as $child_download) {
$child_sales += edd_get_download_sales_stats($child_download);
$child_earnings += edd_get_download_earnings_stats($child_download);
$child_avg_sales += edd_get_average_monthly_download_sales($child_download);
$child_avg_earnings += edd_get_average_monthly_download_earnings($child_download);
}
$child_avg_sales = round($child_avg_sales / count($child_downloads));
$child_avg_earnings = round($child_avg_earnings / count($child_downloads), edd_currency_decimal_filter());
$reports_data[] = array('ID' => $child_term->term_id, 'label' => '— ' . $child_term->name, 'total_sales' => edd_format_amount($child_sales, false), 'total_sales_raw' => $child_sales, 'total_earnings' => edd_currency_filter(edd_format_amount($child_earnings)), 'total_earnings_raw' => $child_earnings, 'avg_sales' => edd_format_amount($child_avg_sales, false), 'avg_earnings' => edd_currency_filter(edd_format_amount($child_avg_earnings)), 'is_child' => true);
}
}
}
set_transient('edd_earnings_by_category_data', $reports_data, HOUR_IN_SECONDS / 4);
}
return $reports_data;
}
示例13: edd_get_average_monthly_download_earnings
/**
* Average Earnings
*
* Retreives the average monthly earnings for a specific download
*
* @access public
* @since 1.3
* @return float
*/
function edd_get_average_monthly_download_earnings($download_id)
{
$earnings = edd_get_download_earnings_stats($download_id);
$release_date = get_post_field('post_date', $download_id);
$diff = abs(time() - strtotime($release_date));
$years = floor($diff / (365 * 60 * 60 * 24));
// number of years since publication
$months = floor(($diff - $years * 365 * 60 * 60 * 24) / (30 * 60 * 60 * 24));
// number of months since publication
if ($months > 0) {
return $earnings / $months;
}
return $earnings;
}
示例14: edd_render_stats_meta_box
/**
* Render Stats Meta Box
*
* @access private
* @since 1.0
* @return void
*/
function edd_render_stats_meta_box()
{
global $post;
$earnings = edd_get_download_earnings_stats($post->ID);
$sales = edd_get_download_sales_stats($post->ID);
echo '<table class="form-table">';
echo '<tr>';
echo '<th style="width:20%">' . __('Sales:', 'edd') . '</th>';
echo '<td class="edd_download_stats">';
echo $sales;
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<th style="width:20%">' . __('Earnings:', 'edd') . '</th>';
echo '<td class="edd_download_stats">';
echo edd_currency_filter($earnings);
echo '</td>';
echo '</tr>';
do_action('edd_stats_meta_box');
echo '</table>';
}
示例15: edd_decrease_earnings
/**
* Decrease Earnings
*
* Decreases the total earnings of a download. Primarily for when a purchase is refunded.
*
* @access public
* @since 1.0.8.1
* @return void
*/
function edd_decrease_earnings($download_id, $amount)
{
$earnings = edd_get_download_earnings_stats($download_id);
if ($earnings > 0) {
// only decrease if greater than zero
$earnings = $earnings - $amount;
}
if (update_post_meta($download_id, '_edd_download_earnings', $earnings)) {
return $earnings;
}
return false;
}