PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.4.1
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.4.1
2.4.1 2.4.0 2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.2 2.1.1 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 All 68 releases
← All changes | includes/Admin/DB.php +46 -19 2.4.0 → 2.4.1 View file →
@@ -2,9 +2,8 @@
2 2
3 3 namespace Better_Payment\Lite\Admin;
4 4
5 5 use Better_Payment\Lite\Classes\Helper;
6 -use Better_Payment\Lite\Classes\ProSubscriptionTransactionData;
7 6
8 7 /**
9 8 * Exit if accessed directly
10 9 */
@@ -157,8 +156,40 @@
157 156 return update_option('better_payment_settings', $value);
158 157 }
159 158
160 159 /**
160 + * The UTC `payment_date` bounds for a date range picked in site time.
161 + *
162 + * The admin date filter sends whole days (`Y-m-d`), picked on the site's
163 + * calendar. Compared as-is, `BETWEEN '2026-10-11' AND '2026-10-11'` matched
164 + * only rows at exactly midnight — so the last day of every range was dropped
165 + * — and the days were UTC days, not the site's. A day bound is widened to the
166 + * whole site day (00:00:00 – 23:59:59) and converted to UTC, which is how
167 + * `payment_date` is stored. A bound that already carries a time is passed
168 + * through unchanged.
169 + *
170 + * @since 2.4.1
171 + *
172 + * @param string $from Lower bound.
173 + * @param string $to Upper bound.
174 + * @return string[] [ from, to ].
175 + */
176 + public static function payment_date_range( $from, $to ) {
177 + $from = trim( (string) $from );
178 + $to = trim( (string) $to );
179 +
180 + if ( preg_match( '/^\d{4}-\d{2}-\d{2}$/', $from ) ) {
181 + $from = get_gmt_from_date( $from . ' 00:00:00', 'Y-m-d H:i:s' );
182 + }
183 +
184 + if ( preg_match( '/^\d{4}-\d{2}-\d{2}$/', $to ) ) {
185 + $to = get_gmt_from_date( $to . ' 23:59:59', 'Y-m-d H:i:s' );
186 + }
187 +
188 + return array( $from, $to );
189 + }
190 +
191 + /**
161 192 * Get all transactions from better payment table.
162 193 *
163 194 * @param array|string $args Filters, as wp_parse_args() reads them (every caller passes an array).
164 195 * @return array
@@ -297,9 +328,10 @@
297 328 }
298 329 }
299 330
300 331 if( $args['payment_date_from'] != '' && $args['payment_date_to'] != ''){
301 - $whereQuery .= $wpdb->prepare(" AND payment_date BETWEEN %s AND %s", $args['payment_date_from'], $args['payment_date_to']);
332 + $range = self::payment_date_range( $args['payment_date_from'], $args['payment_date_to'] );
333 + $whereQuery .= $wpdb->prepare(" AND payment_date BETWEEN %s AND %s", $range[0], $range[1]);
302 334 }
303 335
304 336 if($count_only === 1){
305 337 if($valid_search_text){
@@ -589,12 +621,10 @@
589 621 *
590 622 * 'transactions' (or no type) is every row the user owns. Every other type is
591 623 * defined by `better_payment/db/user_transactions_type_where` ($where, $type),
592 624 * which starts from null: Pro supplies the 'subscriptions' condition for its
593 - * recurring and split payments. Lite's copy of it
594 - * (ProSubscriptionTransactionData::subscriptions_type_where()) serves only an
595 - * active Pro that does not (<= 1.4.3). A type nobody defines returns null, and
596 - * the caller answers with no rows.
625 + * recurring and split payments. A type nobody defines returns null, and the
626 + * caller answers with no rows.
597 627 *
598 628 * @since 2.4.0
599 629 *
600 630 * @param string $type Requested row type.
@@ -604,16 +634,10 @@
604 634 if ( '' === $type || 'transactions' === $type ) {
605 635 return '';
606 636 }
607 637
608 - $where = null;
638 + $where = apply_filters( 'better_payment/db/user_transactions_type_where', null, $type );
609 639
610 - if ( ProSubscriptionTransactionData::lite_copy_applies() ) {
611 - $where = ProSubscriptionTransactionData::subscriptions_type_where( $where, $type );
612 - }
613 -
614 - $where = apply_filters( 'better_payment/db/user_transactions_type_where', $where, $type );
615 -
616 640 return is_string( $where ) ? $where : null;
617 641 }
618 642
619 643 /**
@@ -663,12 +687,15 @@
663 687 /**
664 688 * Get transactions amount
665 689 *
666 690 * Lite never calls this; Better Payment Pro <= 1.4.3's AnalyticsModel does, and
667 - * tests/Unit/ProCouplingContractTest.php pins it. Pro 1.4.4 carries its own copy.
691 + * tests/Unit/ProCouplingContractTest.php pins it. Pro 1.4.4 carries its own copy
692 + * (better-payment-pro/includes/Models/AnalyticsModel.php).
668 693 *
669 - * @deprecated 2.4.0 Kept only for Better Payment Pro <= 1.4.3; delete when MIN_PRO_VERSION >= 1.4.4.
670 - * Pro copy: better-payment-pro/includes/Models/AnalyticsModel.php::get_transactions_by_statuses().
694 + * @deprecated 2.4.0 A fatal guard only: Pro 1.4.3 is unsupported since
695 + * ProCompatibility::MIN_PRO_VERSION 1.4.4, but a site that updates Lite
696 + * first must not fatal on Pro's Analytics screen. Delete once no
697 + * supported site can run Pro 1.4.3.
671 698 *
672 699 * @return array
673 700 * @since 0.0.1
674 701 */
@@ -773,11 +800,11 @@
773 800 /**
774 801 * The SQL count or sum behind get_transactions_amount_by_statuses() when no
775 802 * filtered transactions are passed.
776 803 *
777 - * @deprecated 2.4.0 Kept only for Better Payment Pro <= 1.4.3; delete when MIN_PRO_VERSION >= 1.4.4.
778 - * Pro copy: better-payment-pro/includes/Models/AnalyticsModel.php::transactions_amount_by_statuses_query(),
779 - * kept identical by Pro's AnalyticsModelParityTest.
804 + * @deprecated 2.4.0 A fatal guard only, for Better Payment Pro <= 1.4.3 (see
805 + * get_transactions_by_statuses()). Pro 1.4.4 carries its own copy in
806 + * better-payment-pro/includes/Models/AnalyticsModel.php.
780 807 *
781 808 * @param string $statuses Quoted, comma-separated statuses for IN().
782 809 * @param string $nullDataQuery " OR status IS NULL " or ''.
783 810 * @param string $payment_date_from Lower payment_date bound.