PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.14.1
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.14.1
2.14.2 2.14.1 2.14.0 2.13.0 2.12.0 2.11.0 2.10.0 2.9.0 2.8.0 2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 All 57 releases
← All changes | includes/integrations/class-google-analytics-client.php +4 -14 2.14.2 → 2.14.1 View file →
@@ -120,16 +120,8 @@
120 120
121 121 /**
122 122 * Run analytics report for specified metrics and date range
123 123 *
124 - * The window is exactly `$date_range` days long and ends yesterday (UTC):
125 - * "30d" is the 30 complete days before today. GA4's startDate and endDate
126 - * are both inclusive, so the start is `days - 1` days before the end.
127 - * Today is left out because it is a partial day, which is also what
128 - * GA4's own "Last 30 days" does. Search Console ends two days earlier
129 - * (D-2) because its data lags; GA4's does not, so it is not held back
130 - * to match (#923).
131 - *
132 124 * @param string $date_range Date range ('7d', '30d', '90d')
133 125 * @param array $metrics Metrics to retrieve (GA4 metric names)
134 126 * @param array $dimensions Dimensions to group by
135 127 * @return array Analytics report data
@@ -137,14 +129,12 @@
137 129 */
138 130 public function run_report(string $date_range = '30d', array $metrics = ['sessions'], array $dimensions = []): array {
139 131 $endpoint = "/{$this->property_id}:runReport";
140 132
141 - // Convert date range to start/end dates, from one anchor so a request
142 - // straddling midnight cannot mix two days.
143 - $days = max(1, (int) str_replace('d', '', $date_range));
144 - $end_ts = strtotime('-1 day', time());
145 - $end_date = gmdate('Y-m-d', $end_ts);
146 - $start_date = gmdate('Y-m-d', strtotime('-' . ($days - 1) . ' days', $end_ts));
133 + // Convert date range to start/end dates
134 + $end_date = gmdate('Y-m-d');
135 + $days = (int) str_replace('d', '', $date_range);
136 + $start_date = gmdate('Y-m-d', strtotime("-{$days} days"));
147 137
148 138 $request_body = [
149 139 'dateRanges' => [
150 140 [