コード例 #1
0
ファイル: Analytics.php プロジェクト: Vatia13/tofido
 public function actionHeatmaps()
 {
     if (!$this->_assertLinkedAccount()) {
         return;
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         // sanitize
         $regEx = '#[^a-z0-9\\:\\-\\=\\|\\ \\;]#i';
         $_POST['metric'] = preg_replace($regEx, '', @$_POST['metric']);
         $_POST['segment'] = preg_replace($regEx, '', @$_POST['segment']);
         $_POST['end'] = absint(@$_POST['end']);
         $_POST['weeks'] = absint(@$_POST['weeks']);
         if (empty($_POST['page_path'])) {
             $_POST['page_path'] = false;
         }
         if (!DigitalPointBetterAnalytics_Helper_Api::check()) {
             if (array_search($_POST['metric'], array('ga:users', 'ga:sessions', 'ga:hits', 'ga:organicSearches')) === false) {
                 wp_send_json(array('error' => sprintf(__('Not all metrics are available for unlicensed copies of the Better Analytics plugin.%1$s%2$sYou can license a copy over here.%3$s%1$sIf this is a valid license, make sure the purchaser of the add-on has verified ownership of this domain %4$sover here%3$s.', 'better-analytics'), '<br /><br />', '<a href="' . esc_url(BETTER_ANALYTICS_PRO_PRODUCT_URL . '#utm_source=admin_reports_ajax&utm_medium=wordpress&utm_campaign=plugin') . '" target="_blank">', '</a>', '<a href="' . esc_url('https://forums.digitalpoint.com/marketplace/domain-verification#utm_source=admin_reports_ajax&utm_medium=wordpress&utm_campaign=plugin') . '" target="_blank">')));
             }
         }
         if ($_POST['page_path']) {
             $_POST['metric'] .= (strpos($_POST['metric'], '|') ? ';' : '|') . 'ga:pagePath==' . $_POST['page_path'];
         }
         $heatmapData = DigitalPointBetterAnalytics_Helper_Reporting::getInstance()->getWeeklyHeatmap($_POST['end'], $_POST['weeks'], $_POST['metric'], $_POST['segment']);
         wp_send_json(array('heatmap_data' => $heatmapData));
     }
     $heatmapData = DigitalPointBetterAnalytics_Helper_Reporting::getInstance()->getWeeklyHeatmap(1, 4, 'ga:sessions' . (!empty($_REQUEST['page_path']) ? '|ga:pagePath==' . $_REQUEST['page_path'] : ''));
     $_hourMap = array();
     for ($i = 0; $i < 24; $i++) {
         $_hourMap[$i] = date('g A', $i * 3600);
     }
     $this->_view('reports/heatmaps', array('heatmap_data' => $heatmapData, 'metrics' => DigitalPointBetterAnalytics_Model_Reporting::getMetrics(), 'segments' => DigitalPointBetterAnalytics_Model_Reporting::getSegments(), 'hour_map' => $_hourMap));
 }