Skip to content

Commit

Permalink
Merge pull request #9290 from awesomemotive/release/3.0.1
Browse files Browse the repository at this point in the history
Release/3.0.1
  • Loading branch information
cklosowski authored Jul 15, 2022
2 parents 89d4074 + 062c1b9 commit adf7b24
Show file tree
Hide file tree
Showing 18 changed files with 148 additions and 111 deletions.
4 changes: 2 additions & 2 deletions easy-digital-downloads.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: The easiest way to sell digital products with WordPress.
* Author: Easy Digital Downloads
* Author URI: https://easydigitaldownloads.com
* Version: 3.0
* Version: 3.0.1
* Text Domain: easy-digital-downloads
* Domain Path: languages
* Requires PHP: 5.6
Expand All @@ -26,7 +26,7 @@
* @package EDD
* @category Core
* @author Easy Digital Downloads
* @version 3.0
* @version 3.0.1
*/

// Exit if accessed directly.
Expand Down
20 changes: 11 additions & 9 deletions includes/admin/customers/customer-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,13 @@ function edd_add_customer_email( $args = array() ) {
);

} else {
$email = sanitize_email( $args['email'] );
$customer_id = (int) $args['customer_id'];
$primary = 'true' === $args['primary'] ? true : false;
$customer = new EDD_Customer( $customer_id );
$email = sanitize_email( $args['email'] );
$customer_id = (int) $args['customer_id'];
$primary = 'true' === $args['primary'] ? true : false;
$customer = new EDD_Customer( $customer_id );
$customer_email_id = $customer->add_email( $email, $primary );

if ( false === $customer->add_email( $email, $primary ) ) {
if ( false === $customer_email_id ) {

if ( in_array( $email, $customer->emails, true ) ) {
$output = array(
Expand All @@ -245,10 +246,11 @@ function edd_add_customer_email( $args = array() ) {
} else {
$redirect = edd_get_admin_url(
array(
'page' => 'edd-customers',
'view' => 'overview',
'id' => urlencode( $customer_id ),
'edd-message' => 'email-added',
'page' => 'edd-customers',
'view' => 'overview',
'id' => absint( $customer_id ),
'edd-message' => 'email-added',
'edd-email-id' => absint( $customer_email_id ),
)
);
$output = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function get_data() {
);

if ( ! empty( $this->start ) || ! empty( $this->end ) ) {
$args['date_query'] = $this->get_date_query();
$args['date_created_query'] = $this->get_date_query();
}

if ( 0 !== $this->download_id ) {
Expand Down Expand Up @@ -129,7 +129,7 @@ public function get_percentage_complete() {
);

if ( ! empty( $this->start ) || ! empty( $this->end ) ) {
$args['date_query'] = $this->get_date_query();
$args['date_created_query'] = $this->get_date_query();
}

if ( 0 !== $this->download_id ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function get_data() {
);

if ( ! empty( $this->start ) || ! empty( $this->end ) ) {
$args['date_query'] = $this->get_date_query();
$args['date_created_query'] = $this->get_date_query();
}

if ( 'any' === $args['status'] || 'all' === $args['status'] ) {
Expand Down Expand Up @@ -238,7 +238,7 @@ public function get_percentage_complete() {
);

if ( ! empty( $this->start ) || ! empty( $this->end ) ) {
$args['date_query'] = $this->get_date_query();
$args['date_created_query'] = $this->get_date_query();
}

if ( 'any' !== $this->status ) {
Expand Down
16 changes: 8 additions & 8 deletions includes/admin/reporting/reports-callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ function edd_overview_sales_earnings_chart() {
$sql_clauses['orderby'] = 'MONTH(date_created)';

// Now drill down to the smallest unit.
if ( $day_by_day ) {
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'DATE', 'date_created' );
$sql_clauses['orderby'] = 'DATE(date_created)';
} elseif ( $hour_by_hour ) {
if ( $hour_by_hour ) {
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'HOUR', 'date_created' );
$sql_clauses['orderby'] = 'HOUR(date_created)';
} elseif ( $day_by_day ) {
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'DATE', 'date_created' );
$sql_clauses['orderby'] = 'DATE(date_created)';
}

if ( ! empty( $currency ) && array_key_exists( strtoupper( $currency ), edd_get_currencies() ) ) {
Expand Down Expand Up @@ -219,12 +219,12 @@ function edd_overview_refunds_chart() {
$sql_clauses['orderby'] = 'MONTH(date_created)';

// Now drill down to the smallest unit.
if ( $day_by_day ) {
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'DATE', 'date_created' );
$sql_clauses['orderby'] = 'DATE(date_created)';
} elseif ( $hour_by_hour ) {
if ( $hour_by_hour ) {
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'HOUR', 'date_created' );
$sql_clauses['orderby'] = 'HOUR(date_created)';
} elseif ( $day_by_day ) {
$sql_clauses['groupby'] = Reports\get_groupby_date_string( 'DATE', 'date_created' );
$sql_clauses['orderby'] = 'DATE(date_created)';
}

if ( empty( $currency ) || 'convert' === $currency ) {
Expand Down
50 changes: 25 additions & 25 deletions includes/admin/reporting/reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -701,18 +701,18 @@ function edd_register_downloads_report( $reports ) {
'orderby' => 'YEAR(date_created), MONTH(date_created), DAY(date_created)',
);

if ( ! $day_by_day ) {
$sql_clauses = array(
'select' => 'YEAR(date_created) AS year, MONTH(date_created) AS month',
'groupby' => 'YEAR(date_created), MONTH(date_created)',
'orderby' => 'YEAR(date_created), MONTH(date_created)',
);
} elseif ( $hour_by_hour ) {
if ( $hour_by_hour ) {
$sql_clauses = array(
'select' => 'YEAR(date_created) AS year, MONTH(date_created) AS month, DAY(date_created) AS day, HOUR(date_created) AS hour',
'groupby' => 'YEAR(date_created), MONTH(date_created), DAY(date_created), HOUR(date_created)',
'orderby' => 'YEAR(date_created), MONTH(date_created), DAY(date_created), HOUR(date_created)',
);
} elseif ( ! $day_by_day ) {
$sql_clauses = array(
'select' => 'YEAR(date_created) AS year, MONTH(date_created) AS month',
'groupby' => 'YEAR(date_created), MONTH(date_created)',
'orderby' => 'YEAR(date_created), MONTH(date_created)',
);
}

$price_id = ! empty( $download_data['price_id'] )
Expand Down Expand Up @@ -1355,18 +1355,18 @@ function edd_register_payment_gateways_report( $reports ) {
'orderby' => 'YEAR(date_created), MONTH(date_created), DAY(date_created)',
);

if ( ! $day_by_day ) {
$sql_clauses = array(
'select' => 'YEAR(date_created) AS year, MONTH(date_created) AS month',
'groupby' => 'YEAR(date_created), MONTH(date_created)',
'orderby' => 'YEAR(date_created), MONTH(date_created)',
);
} elseif ( $hour_by_hour ) {
if ( $hour_by_hour ) {
$sql_clauses = array(
'select' => 'YEAR(date_created) AS year, MONTH(date_created) AS month, DAY(date_created) AS day, HOUR(date_created) AS hour',
'groupby' => 'YEAR(date_created), MONTH(date_created), DAY(date_created), HOUR(date_created)',
'orderby' => 'YEAR(date_created), MONTH(date_created), DAY(date_created), HOUR(date_created)',
);
} elseif ( ! $day_by_day ) {
$sql_clauses = array(
'select' => 'YEAR(date_created) AS year, MONTH(date_created) AS month',
'groupby' => 'YEAR(date_created), MONTH(date_created)',
'orderby' => 'YEAR(date_created), MONTH(date_created)',
);
}

$gateway = Reports\get_filter_value( 'gateways' );
Expand Down Expand Up @@ -1818,12 +1818,12 @@ function edd_register_file_downloads_report( $reports ) {
$sql_clauses['orderby'] = 'MONTH(date_created)';

// Now drill down to the smallest unit.
if ( $day_by_day ) {
$sql_clauses['groupby'] = 'DATE(date_created)';
$sql_clauses['orderby'] = 'DATE(date_created)';
} elseif ( $hour_by_hour ) {
if ( $hour_by_hour ) {
$sql_clauses['groupby'] = 'HOUR(date_created)';
$sql_clauses['orderby'] = 'HOUR(date_created)';
} elseif ( $day_by_day ) {
$sql_clauses['groupby'] = 'DATE(date_created)';
$sql_clauses['orderby'] = 'DATE(date_created)';
}

$product_id = '';
Expand Down Expand Up @@ -2371,18 +2371,18 @@ function edd_register_customer_report( $reports ) {
'orderby' => 'YEAR(date_created), MONTH(date_created), DAY(date_created)',
);

if ( ! $day_by_day ) {
$sql_clauses = array(
'select' => 'YEAR(date_created) AS year, MONTH(date_created) AS month',
'groupby' => 'YEAR(date_created), MONTH(date_created)',
'orderby' => 'YEAR(date_created), MONTH(date_created)',
);
} elseif ( $hour_by_hour ) {
if ( $hour_by_hour ) {
$sql_clauses = array(
'select' => 'YEAR(date_created) AS year, MONTH(date_created) AS month, DAY(date_created) AS day, HOUR(date_created) AS hour',
'groupby' => 'YEAR(date_created), MONTH(date_created), DAY(date_created), HOUR(date_created)',
'orderby' => 'YEAR(date_created), MONTH(date_created), DAY(date_created), HOUR(date_created)',
);
} elseif ( ! $day_by_day ) {
$sql_clauses = array(
'select' => 'YEAR(date_created) AS year, MONTH(date_created) AS month',
'groupby' => 'YEAR(date_created), MONTH(date_created)',
'orderby' => 'YEAR(date_created), MONTH(date_created)',
);
}

$results = $wpdb->get_results( $wpdb->prepare(
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/settings/register-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ function edd_get_registered_settings() {
'id' => 'debug_mode',
'name' => __( 'Debug Mode', 'easy-digital-downloads' ),
'check' => __( 'Enabled', 'easy-digital-downloads' ),
'desc' => sprintf( __( 'Check this to enable logging of certain behaviors to a file. %s', 'easy-digital-downloads' ), $debug_log_link ),
'desc' => __( 'Check this box to enable Debug Mode.', 'easy-digital-downloads' ) . ' ' . $debug_log_link,
'type' => 'checkbox_description',
),
'disable_styles' => array(
Expand Down
2 changes: 1 addition & 1 deletion includes/class-easy-digital-downloads.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ private function setup_constants() {

// Plugin version.
if ( ! defined( 'EDD_VERSION' ) ) {
define( 'EDD_VERSION', '3.0' );
define( 'EDD_VERSION', '3.0.1' );
}

// Plugin Root File.
Expand Down
15 changes: 9 additions & 6 deletions includes/class-edd-customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,12 @@ public function update( $data = array() ) {
* Attach an email address to the customer.
*
* @since 2.6
* @since 3.0.1 This method will return customer email ID or false, instead of bool
*
* @param string $email The email address to remove from the customer.
* @param bool $primary Allows setting the email added as the primary.
*
* @return bool True if the email was added successfully, false otherwise.
* @return int|false ID of newly created customer email address, false on error.
*/
public function add_email( $email = '', $primary = false ) {
if ( ! is_email( $email ) ) {
Expand All @@ -389,11 +390,13 @@ public function add_email( $email = '', $primary = false ) {
: 'secondary';

// Update is used to ensure duplicate emails are not added.
$ret = (bool) edd_add_customer_email_address( array(
'customer_id' => $this->id,
'email' => $email,
'type' => $type
) );
$ret = edd_add_customer_email_address(
array(
'customer_id' => $this->id,
'email' => $email,
'type' => $type,
)
);

do_action( 'edd_customer_post_add_email', $email, $this->id, $this );

Expand Down
13 changes: 9 additions & 4 deletions includes/class-edd-session.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,16 @@ public function __construct() {
add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 );
}

$hook = ( empty( $this->session ) && ! $this->use_php_sessions )
? 'plugins_loaded'
: 'init';
// Based off our session handling, we need to use different hooks and priorities.
if ( empty( $this->session ) && ! $this->use_php_sessions ) {
$hook = 'plugins_loaded';
$priority = 10;
} else {
$hook = 'init';
$priority = -1;
}

add_action( $hook, array( $this, 'init' ), -1 );
add_action( $hook, array( $this, 'init' ), $priority );
}

/**
Expand Down
5 changes: 5 additions & 0 deletions includes/class-structured-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ public function generate_download_data( $download = false ) {
return false;
}

// Return false if a download object could not be retrieved.
if ( ! $download instanceof \EDD_Download ) {
return false;
}

$data = array(
'@type' => 'Product',
'name' => $download->post_title,
Expand Down
14 changes: 7 additions & 7 deletions includes/reports/data/charts/v2/class-manifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@ public function build_config() {

$time_format = 'MMM YYYY';

if ( $day_by_day ) {
$time_format = 'MMM D';
} else if ( $hour_by_hour ) {
if ( $hour_by_hour ) {
$time_format = 'hA';
} else if ( $day_by_day ) {
$time_format = 'MMM D';
}

$config->type = $this->get_type();
Expand Down Expand Up @@ -433,12 +433,12 @@ public function get_chart_options() {
$time_unit = 'month';
$time_format = 'MMM YYYY';

if ( $day_by_day ) {
$time_unit = 'day';
$time_format = 'MMM D';
} else if ( $hour_by_hour ) {
if ( $hour_by_hour ) {
$time_unit = 'hour';
$time_format = 'hA';
} else if ( $day_by_day ) {
$time_unit = 'day';
$time_format = 'MMM D';
}

$defaults = array(
Expand Down
6 changes: 6 additions & 0 deletions includes/reports/reports-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,12 @@ function get_dates_filter_hour_by_hour() {
case 'yesterday':
$hour_by_hour = true;
break;
case 'other':
$difference = ( $dates['end']->getTimestamp() - $dates['start']->getTimestamp() );
if ( $difference <= ( DAY_IN_SECONDS * 2 ) ) {
$hour_by_hour = true;
}
break;
default:
$hour_by_hour = false;
break;
Expand Down
Loading

0 comments on commit adf7b24

Please sign in to comment.