id ) ) { return false; } // Must be a completed or renewal order. if ( ! in_array( $order->status, [ 'complete', 'renewal' ], true ) ) { return false; } // Convert creation date to timestamp in the site's timezone. $order_ts = 0; try { $order_ts = EDD()->utils->date( $order->date_created, null, true )->getTimestamp(); } catch ( Exception $e ) { $order_ts = is_string( $order->date_created ) ? strtotime( $order->date_created ) : 0; } if ( ! $order_ts ) { return false; } $current_ts = current_time( 'timestamp' ); $period_seconds = (int) EDD_REFUND_COLUMN_PERIOD_DAYS * DAY_IN_SECONDS; return ( $order_ts >= ( $current_ts - $period_seconds ) ); } /** * Outputs the “Request Refund” table cell. * * @since 1.0.0 * * @param \EDD\Order $order EDD order object for the current row. * @return void */ function gk_edd_refund_column_add_cell( $order ) { $cell_open = ''; $cell_close = ''; if ( ! gk_edd_refund_column_is_eligible( $order ) ) { echo $cell_open . '—' . $cell_close; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped return; } $refund_url = add_query_arg( EDD_REFUND_COLUMN_QUERY_ARG, rawurlencode( (string) $order->id ), get_permalink( EDD_REFUND_COLUMN_PAGE_ID ) ); printf( '%1$s%3$s%4$s', $cell_open, esc_url( $refund_url ), esc_html__( 'Request Refund', 'edd-refund-column' ), $cell_close ); }