Slightly better date handling

This commit is contained in:
claudiulodro 2017-05-12 12:59:54 -07:00
parent 3861e32803
commit 2ce90b3eb6
1 changed files with 16 additions and 2 deletions

View File

@ -109,8 +109,22 @@ function wc_get_orders( $args ) {
}
// Map legacy date args to modern date args.
$date_before = ! empty( $args['date_before'] ) ? strtotime( $args['date_before'] ) : false;
$date_after = ! empty( $args['date_after'] ) ? strtotime( $args['date_after'] ) : false;
$date_before = false;
$date_after = false;
if ( ! empty( $args['date_before'] ) ) {
$date_before = strtotime( $args['date_before'] );
if ( $date_before && ! strpos( $args['date_before'], ':' ) ) {
$date_before = date( 'Y-m-d', $date_before );
}
}
if ( ! empty ( $args['date_after'] ) ) {
$date_after = strtotime( $args['date_after'] );
if ( $date_after && ! strpos( $args['date_after'], ':' ) ) {
$date_after = date( 'Y-m-d', $date_after );
}
}
if ( $date_before && $date_after ) {
$args['date_created'] = $date_before . '...' . $date_after;
} elseif ( $date_before ) {