Feedback
This commit is contained in:
parent
04d7ccfaa4
commit
eddd7fbfb4
|
@ -58,7 +58,8 @@ class WC_Report_Downloads extends WP_List_Table {
|
|||
|
||||
// Subtitle for permission if set.
|
||||
if ( isset( $_GET['permission_id'] ) && is_numeric( $_GET['permission_id'] ) && $_GET['permission_id'] > 0 ) {
|
||||
$permission_id = $_GET['permission_id'];
|
||||
$permission_id = absint( $_GET['permission_id'] ); // WPCS: input var ok.
|
||||
|
||||
// Load the permission, order, etc. so we can render more information.
|
||||
$permission = null;
|
||||
$product = null;
|
||||
|
@ -66,7 +67,7 @@ class WC_Report_Downloads extends WP_List_Table {
|
|||
$permission = new WC_Customer_Download( $permission_id );
|
||||
$product = wc_get_product( $permission->product_id );
|
||||
} catch ( Exception $e ) {
|
||||
wp_die( sprintf( __( 'Permission #%d not found.', 'woocommerce' ), $permission_id ) );
|
||||
wp_die( sprintf( esc_html__( 'Permission #%d not found.', 'woocommerce' ), $permission_id ) );
|
||||
}
|
||||
|
||||
if ( ! empty( $permission ) && ! empty( $product ) ) {
|
||||
|
@ -129,12 +130,9 @@ class WC_Report_Downloads extends WP_List_Table {
|
|||
echo esc_html( $item->timestamp );
|
||||
break;
|
||||
case 'product' :
|
||||
if ( empty( $product ) ) {
|
||||
break;
|
||||
if ( ! empty( $product ) ) {
|
||||
edit_post_link( $product->get_formatted_name(), '', '', $product->get_id() );
|
||||
}
|
||||
|
||||
edit_post_link( $product->get_formatted_name(), '', '', $product->get_id() );
|
||||
|
||||
break;
|
||||
case 'order' :
|
||||
if ( ! empty( $permission ) ) {
|
||||
|
@ -229,10 +227,11 @@ class WC_Report_Downloads extends WP_List_Table {
|
|||
|
||||
// Apply filter by permission.
|
||||
if ( isset( $_GET['permission_id'] ) && is_numeric( $_GET['permission_id'] ) && $_GET['permission_id'] > 0 ) {
|
||||
$permission_id = absint( $_GET['permission_id'] ); // WPCS: input var ok.
|
||||
|
||||
// Ensure the permission and product exist.
|
||||
try {
|
||||
$permission = new WC_Customer_Download( $_GET['permission_id'] );
|
||||
$permission = new WC_Customer_Download( $permission_id );
|
||||
$product = wc_get_product( $permission->product_id );
|
||||
} catch ( Exception $e ) {
|
||||
// Leave array empty since we can't find the permission.
|
||||
|
@ -240,7 +239,7 @@ class WC_Report_Downloads extends WP_List_Table {
|
|||
}
|
||||
|
||||
// Add filter for permission id.
|
||||
$query_from .= $wpdb->prepare( "AND permission_id = %d", $_GET['permission_id'] );
|
||||
$query_from .= $wpdb->prepare( "AND permission_id = %d", $permission_id );
|
||||
}
|
||||
|
||||
$query_from = apply_filters( 'woocommerce_report_downloads_query_from', $query_from );
|
||||
|
|
|
@ -145,29 +145,4 @@ class WC_Customer_Download_Log extends WC_Data {
|
|||
public function set_user_ip_address( $value ) {
|
||||
$this->set_prop( 'user_ip_address', $value );
|
||||
}
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| CRUD methods
|
||||
|--------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* Save data to the database.
|
||||
*
|
||||
* @return int Log ID
|
||||
*/
|
||||
public function save() {
|
||||
if ( $this->data_store ) {
|
||||
// Trigger action before saving to the DB. Use a pointer to adjust object props before save.
|
||||
do_action( 'woocommerce_before_' . $this->object_type . '_object_save', $this, $this->data_store );
|
||||
|
||||
if ( $this->get_id() ) {
|
||||
$this->data_store->update( $this );
|
||||
} else {
|
||||
$this->data_store->create( $this );
|
||||
}
|
||||
}
|
||||
return $this->get_id();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ class WC_Tests_Customer_Download_Log extends WC_Unit_Test_Case {
|
|||
$set_to = current_time( 'timestamp', true );
|
||||
|
||||
// Convert timestamp to WC_DateTime using ISO 8601 for PHP 5.2 compat.
|
||||
$dtStr = date("c", $set_to);
|
||||
$wc_timestamp = new WC_DateTime($dtStr);
|
||||
$dt_str = date( 'c', $set_to );
|
||||
$wc_timestamp = new WC_DateTime( $dt_str );
|
||||
|
||||
$object->set_timestamp( $set_to );
|
||||
$this->assertEquals( $wc_timestamp, $object->get_timestamp() );
|
||||
|
@ -78,8 +78,8 @@ class WC_Tests_Customer_Download_Log extends WC_Unit_Test_Case {
|
|||
$timestamp = current_time( 'timestamp', true );
|
||||
|
||||
// Convert timestamp to WC_DateTime using ISO 8601 for PHP 5.2 compat.
|
||||
$dtStr = date("c", $timestamp);
|
||||
$wc_timestamp = new WC_DateTime($dtStr);
|
||||
$dt_str = date( 'c', $timestamp );
|
||||
$wc_timestamp = new WC_DateTime( $dt_str );
|
||||
|
||||
$download_log = new WC_Customer_Download_Log;
|
||||
$download_log->set_timestamp( $timestamp );
|
||||
|
|
Loading…
Reference in New Issue