updated plugin Easy Digital Downloads
version 3.1.0.4
This commit is contained in:
@ -450,4 +450,33 @@ class EDD_Customer_Addresses_Table extends List_Table {
|
||||
'per_page' => $this->per_page
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the table navigation above or below the table.
|
||||
* We're overriding this to turn off the referer param in `wp_nonce_field()`.
|
||||
*
|
||||
* @param string $which
|
||||
* @since 3.1.0.4
|
||||
*/
|
||||
protected function display_tablenav( $which ) {
|
||||
if ( 'top' === $which ) {
|
||||
wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false );
|
||||
}
|
||||
?>
|
||||
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
||||
|
||||
<?php if ( $this->has_items() ) : ?>
|
||||
<div class="alignleft actions bulkactions">
|
||||
<?php $this->bulk_actions( $which ); ?>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
$this->extra_tablenav( $which );
|
||||
$this->pagination( $which );
|
||||
?>
|
||||
|
||||
<br class="clear"/>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
@ -437,4 +437,33 @@ class EDD_Customer_Email_Addresses_Table extends List_Table {
|
||||
'per_page' => $this->per_page
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the table navigation above or below the table.
|
||||
* We're overriding this to turn off the referer param in `wp_nonce_field()`.
|
||||
*
|
||||
* @param string $which
|
||||
* @since 3.1.0.4
|
||||
*/
|
||||
protected function display_tablenav( $which ) {
|
||||
if ( 'top' === $which ) {
|
||||
wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false );
|
||||
}
|
||||
?>
|
||||
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
||||
|
||||
<?php if ( $this->has_items() ) : ?>
|
||||
<div class="alignleft actions bulkactions">
|
||||
<?php $this->bulk_actions( $which ); ?>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
$this->extra_tablenav( $which );
|
||||
$this->pagination( $which );
|
||||
?>
|
||||
|
||||
<br class="clear"/>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
@ -430,4 +430,33 @@ class EDD_Customer_Reports_Table extends List_Table {
|
||||
'per_page' => $this->per_page,
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the table navigation above or below the table.
|
||||
* We're overriding this to turn off the referer param in `wp_nonce_field()`.
|
||||
*
|
||||
* @param string $which
|
||||
* @since 3.1.0.4
|
||||
*/
|
||||
protected function display_tablenav( $which ) {
|
||||
if ( 'top' === $which ) {
|
||||
wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false );
|
||||
}
|
||||
?>
|
||||
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
||||
|
||||
<?php if ( $this->has_items() ) : ?>
|
||||
<div class="alignleft actions bulkactions">
|
||||
<?php $this->bulk_actions( $which ); ?>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
$this->extra_tablenav( $which );
|
||||
$this->pagination( $which );
|
||||
?>
|
||||
|
||||
<br class="clear"/>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
@ -427,4 +427,33 @@ class EDD_Discount_Codes_Table extends List_Table {
|
||||
'per_page' => $this->per_page,
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the table navigation above or below the table.
|
||||
* We're overriding this to turn off the referer param in `wp_nonce_field()`.
|
||||
*
|
||||
* @param string $which
|
||||
* @since 3.1.0.4
|
||||
*/
|
||||
protected function display_tablenav( $which ) {
|
||||
if ( 'top' === $which ) {
|
||||
wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false );
|
||||
}
|
||||
?>
|
||||
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
||||
|
||||
<?php if ( $this->has_items() ) : ?>
|
||||
<div class="alignleft actions bulkactions">
|
||||
<?php $this->bulk_actions( $which ); ?>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
$this->extra_tablenav( $which );
|
||||
$this->pagination( $which );
|
||||
?>
|
||||
|
||||
<br class="clear"/>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
@ -226,33 +226,52 @@ add_action( 'load-edit.php', 'edd_download_load', 9999 );
|
||||
function edd_add_download_filters() {
|
||||
global $typenow;
|
||||
|
||||
// Checks if the current post type is 'download'
|
||||
if ( $typenow !== 'download') {
|
||||
// Checks if the current post type is 'download'.
|
||||
if ( 'download' !== $typenow ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$terms = get_terms( 'download_category' );
|
||||
if ( count( $terms ) > 0 ) {
|
||||
echo "<select name='download_category' id='download_category' class='postform'>";
|
||||
$category_labels = edd_get_taxonomy_labels( 'download_category' );
|
||||
echo "<option value=''>" . sprintf( __( 'All %s', 'easy-digital-downloads' ), strtolower( $category_labels['name'] ) ) . "</option>";
|
||||
foreach ( $terms as $term ) {
|
||||
$selected = isset( $_GET['download_category'] ) && $_GET['download_category'] === $term->slug ? ' selected="selected"' : '';
|
||||
echo '<option value="' . esc_attr( $term->slug ) . '"' . $selected . '>' . esc_html( $term->name ) .' (' . $term->count .')</option>';
|
||||
}
|
||||
echo "</select>";
|
||||
}
|
||||
$category_args = array(
|
||||
'taxonomy' => 'download_category',
|
||||
'number' => 30,
|
||||
);
|
||||
|
||||
$terms = get_terms( 'download_tag' );
|
||||
if ( count( $terms ) > 0 ) {
|
||||
echo "<select name='download_tag' id='download_tag' class='postform'>";
|
||||
$tag_labels = edd_get_taxonomy_labels( 'download_tag' );
|
||||
echo "<option value=''>" . sprintf( __( 'All %s', 'easy-digital-downloads' ), strtolower( $tag_labels['name'] ) ) . "</option>";
|
||||
foreach ( $terms as $term ) {
|
||||
$selected = isset( $_GET['download_tag']) && $_GET['download_tag'] === $term->slug ? ' selected="selected"' : '';
|
||||
echo '<option value="' . esc_attr( $term->slug ) . '"' . $selected . '>' . esc_html( $term->name ) .' (' . $term->count .')</option>';
|
||||
}
|
||||
echo "</select>";
|
||||
$categories = get_terms( $category_args );
|
||||
if ( ! empty( $categories ) ) {
|
||||
$category_labels = edd_get_taxonomy_labels( 'download_category' );
|
||||
|
||||
$options = array();
|
||||
$options[''] = sprintf( _x( 'All %s', 'plural: Example: "All Categories"', 'easy-digital-downloads' ), $category_labels['name'] );
|
||||
|
||||
// Ensure we include the selected value in the pre-populated list.
|
||||
$selected = ! empty( $_GET['download_category'] ) ? $_GET['download_category'] : '';
|
||||
if ( ! empty( $selected ) ) {
|
||||
$selected_term = get_term_by( 'slug', $selected, 'download_category' );
|
||||
|
||||
$options[ $selected_term->slug ] = $selected_term->name . ' (' . $selected_term->count . ')';
|
||||
}
|
||||
|
||||
foreach ( $categories as $category ) {
|
||||
$options[ $category->slug ] = $category->name . ' (' . $category->count . ')';
|
||||
}
|
||||
|
||||
echo EDD()->html->select(
|
||||
array(
|
||||
'name' => 'download_category',
|
||||
'id' => 'download_category',
|
||||
'class' => 'postform',
|
||||
'chosen' => true,
|
||||
'show_option_all' => false,
|
||||
'show_option_none' => false,
|
||||
'options' => $options,
|
||||
'selected' => $selected,
|
||||
'data' => array(
|
||||
'placeholder' => sprintf( _x( 'Search %s', 'plural: Example: "Search Download Categories"', 'easy-digital-downloads' ), $category_labels['name'] ),
|
||||
'search-type' => 'download_category',
|
||||
'search-placeholder' => sprintf( _x( 'Search %s', 'plural: Example: "Search Download Categories"', 'easy-digital-downloads' ), $category_labels['name'] ),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) {
|
||||
|
@ -1057,4 +1057,33 @@ class EDD_Payment_History_Table extends List_Table {
|
||||
'per_page' => $this->per_page,
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the table navigation above or below the table.
|
||||
* We're overriding this to turn off the referer param in `wp_nonce_field()`.
|
||||
*
|
||||
* @param string $which
|
||||
* @since 3.1.0.4
|
||||
*/
|
||||
protected function display_tablenav( $which ) {
|
||||
if ( 'top' === $which ) {
|
||||
wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false );
|
||||
}
|
||||
?>
|
||||
<div class="tablenav <?php echo esc_attr( $which ); ?>">
|
||||
|
||||
<?php if ( $this->has_items() ) : ?>
|
||||
<div class="alignleft actions bulkactions">
|
||||
<?php $this->bulk_actions( $which ); ?>
|
||||
</div>
|
||||
<?php
|
||||
endif;
|
||||
$this->extra_tablenav( $which );
|
||||
$this->pagination( $which );
|
||||
?>
|
||||
|
||||
<br class="clear"/>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
@ -745,39 +745,85 @@ function edd_register_downloads_report( $reports ) {
|
||||
'groupby' => '',
|
||||
);
|
||||
|
||||
$union_clauses = array(
|
||||
'select' => 'date',
|
||||
'where' => '',
|
||||
'groupby' => '',
|
||||
);
|
||||
|
||||
// Default to 'monthly'.
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'MONTH', 'edd_oi.date_created' );
|
||||
$sql_clauses['orderby'] = 'MONTH(edd_oi.date_created)';
|
||||
|
||||
$union_clauses['groupby'] = Reports\get_groupby_date_string( 'MONTH', 'date' );
|
||||
$union_clauses['orderby'] = 'MONTH(date)';
|
||||
|
||||
// Now drill down to the smallest unit.
|
||||
if ( $hour_by_hour ) {
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'HOUR', 'edd_oi.date_created' );
|
||||
$sql_clauses['orderby'] = 'HOUR(edd_oi.date_created)';
|
||||
|
||||
$union_clauses['groupby'] = Reports\get_groupby_date_string( 'HOUR', 'date' );
|
||||
$union_clauses['orderby'] = 'HOUR(date)';
|
||||
} elseif ( $day_by_day ) {
|
||||
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'DATE', 'edd_oi.date_created' );
|
||||
$sql_clauses['orderby'] = 'DATE(edd_oi.date_created)';
|
||||
}
|
||||
|
||||
$union_clauses['groupby'] = Reports\get_groupby_date_string( 'DATE', 'date' );
|
||||
$union_clauses['orderby'] = 'DATE(date)';
|
||||
}
|
||||
|
||||
$price_id = isset( $download_data['price_id'] ) && is_numeric( $download_data['price_id'] )
|
||||
? sprintf( 'AND price_id = %d', absint( $download_data['price_id'] ) )
|
||||
: '';
|
||||
|
||||
$earnings_results = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"SELECT SUM(edd_oi.total / edd_oi.rate) AS earnings, %1s
|
||||
FROM {$wpdb->edd_order_items} edd_oi
|
||||
WHERE edd_oi.product_id = %d %1s AND edd_oi.date_created >= %s AND edd_oi.date_created <= %s AND edd_oi.status IN ( 'complete', 'refunded', 'partially_refunded' )
|
||||
GROUP BY {$sql_clauses['groupby']}
|
||||
ORDER BY {$sql_clauses['orderby']} ASC",
|
||||
$sql_clauses['select'],
|
||||
$download_data['download_id'],
|
||||
$price_id,
|
||||
$dates['start']->copy()->format( 'mysql' ),
|
||||
$dates['end']->copy()->format( 'mysql' )
|
||||
)
|
||||
$earnings_statuses = edd_get_gross_order_statuses();
|
||||
$earnings_status_string = implode( ', ', array_fill( 0, count( $earnings_statuses ), '%s' ) );
|
||||
|
||||
$order_item_earnings = $wpdb->prepare(
|
||||
"SELECT SUM(edd_oi.total / edd_oi.rate) AS earnings, %1s
|
||||
FROM {$wpdb->edd_order_items} edd_oi
|
||||
INNER JOIN {$wpdb->edd_orders} edd_o ON edd_oi.order_id = edd_o.id
|
||||
WHERE edd_oi.product_id = %d %1s AND edd_oi.date_created >= %s AND edd_oi.date_created <= %s AND edd_o.status IN ({$earnings_status_string})
|
||||
GROUP BY {$sql_clauses['groupby']}",
|
||||
$sql_clauses['select'],
|
||||
$download_data['download_id'],
|
||||
$price_id,
|
||||
$dates['start']->copy()->format( 'mysql' ),
|
||||
$dates['end']->copy()->format( 'mysql' ),
|
||||
...$earnings_statuses
|
||||
);
|
||||
|
||||
/**
|
||||
* The adjustments query needs a different order status check than the order items. This is due to the fact that
|
||||
* adjustments refunded would end up being double counted, and therefore create an inaccurate revenue report.
|
||||
*/
|
||||
$adjustments_statuses = edd_get_net_order_statuses();
|
||||
$adjustments_status_string = implode( ', ', array_fill( 0, count( $adjustments_statuses ), '%s' ) );
|
||||
|
||||
$order_adjustments = $wpdb->prepare(
|
||||
"SELECT SUM(edd_oa.total / edd_oa.rate) AS earnings, %1s
|
||||
FROM {$wpdb->edd_order_adjustments} edd_oa
|
||||
INNER JOIN {$wpdb->edd_order_items} edd_oi ON
|
||||
edd_oi.id = edd_oa.object_id
|
||||
AND edd_oi.product_id = %d
|
||||
%1s
|
||||
AND edd_oi.date_created >= %s AND edd_oi.date_created <= %s
|
||||
INNER JOIN {$wpdb->edd_orders} edd_o ON edd_oi.order_id = edd_o.id AND edd_o.type = 'sale' AND edd_o.status IN ({$adjustments_status_string})
|
||||
WHERE edd_oa.object_type = 'order_item'
|
||||
AND edd_oa.type != 'discount'
|
||||
GROUP BY {$sql_clauses['groupby']}",
|
||||
$sql_clauses['select'],
|
||||
$download_data['download_id'],
|
||||
$price_id,
|
||||
$dates['start']->copy()->format( 'mysql' ),
|
||||
$dates['end']->copy()->format( 'mysql' ),
|
||||
...$adjustments_statuses
|
||||
);
|
||||
|
||||
$earnings_sql = "SELECT SUM(earnings) as earnings, {$union_clauses['select']} FROM ({$order_item_earnings} UNION {$order_adjustments})a GROUP BY {$union_clauses['groupby']} ORDER BY {$union_clauses['orderby']}";
|
||||
$earnings_results = $wpdb->get_results( $earnings_sql );
|
||||
|
||||
$statuses = edd_get_net_order_statuses();
|
||||
$status_string = implode( ', ', array_fill( 0, count( $statuses ), '%s' ) );
|
||||
|
||||
@ -786,22 +832,22 @@ function edd_register_downloads_report( $reports ) {
|
||||
...$statuses
|
||||
);
|
||||
|
||||
$sales_results = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"SELECT COUNT(edd_oi.total) AS sales, %1s
|
||||
FROM {$wpdb->edd_order_items} edd_oi
|
||||
{$join}
|
||||
WHERE edd_oi.product_id = %d %1s AND edd_oi.date_created >= %s AND edd_oi.date_created <= %s AND edd_oi.status IN ( 'complete', 'refunded', 'partially_refunded' )
|
||||
GROUP BY {$sql_clauses['groupby']}
|
||||
ORDER BY {$sql_clauses['orderby']} ASC",
|
||||
$sql_clauses['select'],
|
||||
$download_data['download_id'],
|
||||
$price_id,
|
||||
$dates['start']->copy()->format( 'mysql' ),
|
||||
$dates['end']->copy()->format( 'mysql' )
|
||||
)
|
||||
$sales_sql = $wpdb->prepare(
|
||||
"SELECT COUNT(edd_oi.total) AS sales, {$sql_clauses['select']}
|
||||
FROM {$wpdb->edd_order_items} edd_oi
|
||||
{$join}
|
||||
WHERE edd_oi.product_id = %d %1s AND edd_oi.date_created >= %s AND edd_oi.date_created <= %s AND edd_oi.status IN ({$status_string})
|
||||
GROUP BY {$sql_clauses['groupby']}
|
||||
ORDER BY {$sql_clauses['orderby']} ASC",
|
||||
$download_data['download_id'],
|
||||
$price_id,
|
||||
$dates['start']->copy()->format( 'mysql' ),
|
||||
$dates['end']->copy()->format( 'mysql' ),
|
||||
...$statuses
|
||||
);
|
||||
|
||||
$sales_results = $wpdb->get_results( $sales_sql );
|
||||
|
||||
$sales = array();
|
||||
$earnings = array();
|
||||
|
||||
|
Reference in New Issue
Block a user