<img class="gray-areas" src="<?php echo esc_url(plugins_url('images/live-stats-preview.png', dirname(__FILE__))); ?> " width="100%" height="auto" alt="Upgrade to PRO to enjoy full features of Analytify." /> </a> --> <?php // General stats. $stats = get_transient(md5('show-overall-dashboard' . $dashboard_profile_id . $start_date . $end_date)); if (false === $stats) { $stats = $wp_analytify->pa_get_analytics_dashboard('ga:sessions,ga:bounces,ga:newUsers,ga:entrances,ga:pageviews,ga:sessionDuration,ga:avgTimeOnPage,ga:users', $start_date, $end_date); set_transient(md5('show-overall-dashboard' . $dashboard_profile_id . $start_date . $end_date), $stats, 60 * 60 * 20); } if (isset($stats->totalsForAllResults)) { include ANALYTIFY_ROOT_PATH . '/views/admin/general-stats.php'; pa_include_general($wp_analytify, $stats); } // End General stats. // Top Pages stats. $top_page_stats = get_transient(md5('show-top-pages-dashboard' . $dashboard_profile_id . $start_date . $end_date)); if (false === $top_page_stats) { $top_page_stats = $wp_analytify->pa_get_analytics_dashboard('ga:pageviews', $start_date, $end_date, 'ga:PageTitle', '-ga:pageviews', false, 5); set_transient(md5('show-top-pages-dashboard' . $dashboard_profile_id . $start_date . $end_date), $top_page_stats, 60 * 60 * 20); } if (isset($top_page_stats->totalsForAllResults)) { include ANALYTIFY_ROOT_PATH . '/views/admin/top-pages-stats.php'; pa_include_top_pages_stats($wp_analytify, $top_page_stats); } // End Top Pages stats. // Country stats. $country_stats = get_transient(md5('show-country-dashboard' . $dashboard_profile_id . $start_date . $end_date));
public function get_single_front_analytics($content) { global $post, $wp_analytify; $front_access = get_option('post_analytics_access'); if (is_single() || is_page()) { $post_type = get_post_type($post->ID); if (strlen(get_option('analytify_posts_stats_front') < 3)) { return $content; } if (is_array(get_option('analytify_posts_stats_front')) and !in_array($post_type, get_option('analytify_posts_stats_front'))) { return $content; } if (is_array(get_option('post_analytics_exclude_posts_front'))) { if (in_array(get_the_ID(), get_option('post_analytics_exclude_posts_front'))) { return $content; } } // Showing stats to guests if ($front_access[0] == 'every-one' || $this->pa_check_roles($front_access)) { $post_analytics_settings_front = array(); $post_analytics_settings_front = get_option('post_analytics_settings_front'); $urlPost = parse_url(get_permalink($post->ID)); if ($urlPost['host'] == 'localhost') { $filter = 'ga:pagePath==/'; } else { $filter = 'ga:pagePath==' . $urlPost['path'] . ''; } if (get_the_time('Y', $post->ID) < 2005) { $start_date = '2005-01-01'; } else { $start_date = get_the_time('Y-m-d', $post->ID); } $end_date = date('Y-m-d'); ob_start(); include ANALYTIFY_ROOT_PATH . '/inc/front-menus.php'; if (!empty($post_analytics_settings_front)) { if (is_array($post_analytics_settings_front)) { $stats = $this->pa_get_analytics('ga:sessions,ga:bounces,ga:newUsers,ga:entrances,ga:pageviews,ga:sessionDuration,ga:avgTimeOnPage,ga:users', $start_date, $end_date, false, false, $filter); if (isset($stats->totalsForAllResults)) { include ANALYTIFY_ROOT_PATH . '/views/front/general-stats.php'; pa_include_general($this, $stats); } } } $content .= ob_get_contents(); ob_get_clean(); } } return $content; }