← All changes
|
includes/admin/dashboard/class-charitable-dashboard.php
+29
-12
1.8.12.1
→
1.8.13
View file →
| @@ -601,41 +601,51 @@ | ||
| 601 | 601 | * @param string $time_period The time period. |
| 602 | 602 | * @return array |
| 603 | 603 | */ |
| 604 | 604 | public function get_date_range_for_period( $time_period ) { |
| 605 | - $end_date = gmdate( 'Y/m/d' ); | |
| 605 | + /* | |
| 606 | + * Site-local, not UTC: this range feeds Charitable_Reports::get_data(), | |
| 607 | + * which filters on p.post_date (site-local time), so a bound built from | |
| 608 | + * bare UTC excludes part of today's donations on any site whose | |
| 609 | + * timezone is ahead of UTC. Every case below is anchored to the same | |
| 610 | + * site-local "now" so the range is internally consistent. | |
| 611 | + * | |
| 612 | + * @since 1.8.13 | |
| 613 | + */ | |
| 614 | + $now = current_time( 'timestamp', 0 ); | |
| 615 | + $end_date = gmdate( 'Y/m/d', $now ); | |
| 606 | 616 | |
| 607 | 617 | switch ( $time_period ) { |
| 608 | 618 | case 'last-7-days': |
| 609 | - $start_date = gmdate( 'Y/m/d', strtotime( '-7 days' ) ); | |
| 619 | + $start_date = gmdate( 'Y/m/d', strtotime( '-7 days', $now ) ); | |
| 610 | 620 | $days = 7; |
| 611 | 621 | break; |
| 612 | 622 | case 'last-14-days': |
| 613 | - $start_date = gmdate( 'Y/m/d', strtotime( '-14 days' ) ); | |
| 623 | + $start_date = gmdate( 'Y/m/d', strtotime( '-14 days', $now ) ); | |
| 614 | 624 | $days = 14; |
| 615 | 625 | break; |
| 616 | 626 | case 'last-30-days': |
| 617 | - $start_date = gmdate( 'Y/m/d', strtotime( '-30 days' ) ); | |
| 627 | + $start_date = gmdate( 'Y/m/d', strtotime( '-30 days', $now ) ); | |
| 618 | 628 | $days = 30; |
| 619 | 629 | break; |
| 620 | 630 | case 'this-month': |
| 621 | - $start_date = gmdate( 'Y/m/d', strtotime( 'first day of this month' ) ); | |
| 622 | - $days = gmdate( 'j' ); // Current day of month | |
| 631 | + $start_date = gmdate( 'Y/m/d', strtotime( 'first day of this month', $now ) ); | |
| 632 | + $days = gmdate( 'j', $now ); // Current day of month | |
| 623 | 633 | break; |
| 624 | 634 | case 'last-3-months': |
| 625 | - $start_date = gmdate( 'Y/m/d', strtotime( '-3 months' ) ); | |
| 635 | + $start_date = gmdate( 'Y/m/d', strtotime( '-3 months', $now ) ); | |
| 626 | 636 | $days = 90; |
| 627 | 637 | break; |
| 628 | 638 | case 'last-6-months': |
| 629 | - $start_date = gmdate( 'Y/m/d', strtotime( '-6 months' ) ); | |
| 639 | + $start_date = gmdate( 'Y/m/d', strtotime( '-6 months', $now ) ); | |
| 630 | 640 | $days = 180; |
| 631 | 641 | break; |
| 632 | 642 | case 'last-year': |
| 633 | - $start_date = gmdate( 'Y/m/d', strtotime( '-1 year' ) ); | |
| 643 | + $start_date = gmdate( 'Y/m/d', strtotime( '-1 year', $now ) ); | |
| 634 | 644 | $days = 365; |
| 635 | 645 | break; |
| 636 | 646 | default: |
| 637 | - $start_date = gmdate( 'Y/m/d', strtotime( '-7 days' ) ); | |
| 647 | + $start_date = gmdate( 'Y/m/d', strtotime( '-7 days', $now ) ); | |
| 638 | 648 | $days = 7; |
| 639 | 649 | break; |
| 640 | 650 | } |
| 641 | 651 | |
| @@ -1179,11 +1189,18 @@ | ||
| 1179 | 1189 | } |
| 1180 | 1190 | |
| 1181 | 1191 | // Get latest donations using Charitable_Reports |
| 1182 | 1192 | $charitable_reports = Charitable_Reports::get_instance(); |
| 1193 | + /* | |
| 1194 | + * Site-local, not UTC: post_date is stored in site-local time, so a | |
| 1195 | + * bound built from bare UTC excludes part of today's donations on any | |
| 1196 | + * site whose timezone is ahead of UTC. | |
| 1197 | + * | |
| 1198 | + * @since 1.8.13 | |
| 1199 | + */ | |
| 1183 | 1200 | $args = array( |
| 1184 | - 'start_date' => gmdate( 'Y/m/d', strtotime( '-30 days' ) ), | |
| 1185 | - 'end_date' => gmdate( 'Y/m/d' ), | |
| 1201 | + 'start_date' => gmdate( 'Y/m/d', current_time( 'timestamp', 0 ) - ( 30 * DAY_IN_SECONDS ) ), | |
| 1202 | + 'end_date' => gmdate( 'Y/m/d', current_time( 'timestamp', 0 ) ), | |
| 1186 | 1203 | 'days' => 30, |
| 1187 | 1204 | ); |
| 1188 | 1205 | $charitable_reports->init_with_array( 'dashboard', $args ); |
| 1189 | 1206 | $donations = $charitable_reports->get_donations(); |