Commit 00d91145 authored by Canek Peláez's avatar Canek Peláez
Browse files

Use dictionaries, not arrays.

parent f7d3cfa2
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -67,17 +67,18 @@ class GAPageStats {
        $reports = $ga->analytics->reports->batchGet($body);

        if (count($reports) == 0)
            return [0, 0];
            return array('pageViews' => 0, 'users' => 0);

        $report = $reports[0];
        $rows = $report->getData()->getRows();

        if (count($rows) == 0)
            return [0, 0];
            return array('pageViews' => 0, 'users' => 0);

        $row = $rows[0];
        $metrics = $row->getMetrics();
        $values = $metrics[0]->getValues();
        return [ $values[0], $values[1] ];
        return array('pageViews' => $values[0],
                     'users'     => $values[1]);
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -28,10 +28,10 @@ function ga_page_stats_content_filter($content) {
        !current_user_can('administrator'))
        return $content;
    $r = GAPageStats::getPageStats($_SERVER['REQUEST_URI']);
    $spv = number_format($r[0]);
    $su = number_format($r[1]);
    return $content . '<span style="font-size:small;"><em>Vistas: ' . $spv .
        '</em> | <em>Usuarios: ' . $su . '</em> | </span>';
    $pv = number_format($r['pageViews']);
    $u = number_format($r['users']);
    return $content . '<span style="font-size:small;"><em>Vistas: ' . $pv .
        '</em> | <em>Usuarios: ' . $u . '</em> | </span>';
}

register_activation_hook(__FILE__, 'ga_page_stats_activation');