Example #1
0
function gadash_front_init()
{
    /*
     * Include config
     */
    include_once dirname(__FILE__) . '/config.php';
    global $GADASH_Config;
    /*
     * Include Tools
     */
    include_once $GADASH_Config->plugin_path . '/tools/tools.php';
    $tools = new GADASH_Tools();
    /*
     * Include frontend stats
     */
    if ($tools->check_roles($GADASH_Config->options['ga_dash_access_front']) and ($GADASH_Config->options['ga_dash_frontend_stats'] or $GADASH_Config->options['ga_dash_frontend_keywords'])) {
        include_once dirname(__FILE__) . '/front/frontend.php';
    }
    /*
     * Include tracking
     */
    if (!$tools->check_roles($GADASH_Config->options['ga_track_exclude'], true) and $GADASH_Config->options['ga_dash_tracking']) {
        include_once dirname(__FILE__) . '/front/tracking.php';
    }
    /*
     * Include frontend widgets
     */
    include_once dirname(__FILE__) . '/front/widgets.php';
}
 /**
  * Ajax handler for Admin Widget
  *
  * @return json|int
  */
 function ajax_widget_reports()
 {
     global $GADASH_Config;
     if (!isset($_REQUEST['gadash_security_widget_reports']) or !wp_verify_nonce($_REQUEST['gadash_security_widget_reports'], 'gadash_get_widgetreports')) {
         wp_die(-30);
     }
     $projectId = $_REQUEST['projectId'];
     $from = $_REQUEST['from'];
     $to = $_REQUEST['to'];
     $query = $_REQUEST['query'];
     if (ob_get_length()) {
         ob_clean();
     }
     $tools = new GADASH_Tools();
     if (!$tools->check_roles($GADASH_Config->options['ga_dash_access_back']) or 0 == $GADASH_Config->options['dashboard_widget']) {
         wp_die(-31);
     }
     if ($GADASH_Config->options['ga_dash_token'] and $projectId and $from and $to) {
         include_once $GADASH_Config->plugin_path . '/tools/gapi.php';
         global $GADASH_GAPI;
     } else {
         wp_die(-24);
     }
     $profile_info = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $projectId);
     if (isset($profile_info[4])) {
         $GADASH_GAPI->timeshift = $profile_info[4];
     } else {
         $GADASH_GAPI->timeshift = (int) current_time('timestamp') - time();
     }
     $GADASH_GAPI->get($projectId, $query, $from, $to);
 }
Example #3
0
 function ga_dash_tracking()
 {
     global $GADASH_Config;
     /*
      * Include Tools
      */
     include_once $GADASH_Config->plugin_path . '/tools/tools.php';
     $tools = new GADASH_Tools();
     if ($tools->check_roles($GADASH_Config->options['ga_track_exclude'], true) or $GADASH_Config->options['ga_dash_excludesa'] and current_user_can('manage_network')) {
         return;
     }
     $traking_mode = $GADASH_Config->options['ga_dash_tracking'];
     $traking_type = $GADASH_Config->options['ga_dash_tracking_type'];
     if ($traking_mode > 0) {
         if (!$GADASH_Config->options['ga_dash_tableid_jail']) {
             return;
         }
         if ($traking_type == "classic") {
             echo "\n<!-- BEGIN GADWP v" . GADWP_CURRENT_VERSION . " Classic Tracking - https://deconf.com/google-analytics-dashboard-wordpress/ -->\n";
             if ($GADASH_Config->options['ga_event_tracking']) {
                 require_once 'tracking/events-classic.php';
             }
             require_once 'tracking/code-classic.php';
             echo "\n<!-- END GADWP Classic Tracking -->\n\n";
         } else {
             echo "\n<!-- BEGIN GADWP v" . GADWP_CURRENT_VERSION . " Universal Tracking - https://deconf.com/google-analytics-dashboard-wordpress/ -->\n";
             if ($GADASH_Config->options['ga_event_tracking'] or $GADASH_Config->options['ga_aff_tracking'] or $GADASH_Config->options['ga_hash_tracking']) {
                 require_once 'tracking/events-universal.php';
             }
             require_once 'tracking/code-universal.php';
             echo "\n<!-- END GADWP Universal Tracking -->\n\n";
         }
     }
 }
 function add_widget()
 {
     global $GADASH_Config;
     $tools = new GADASH_Tools();
     if ($tools->check_roles($GADASH_Config->options['ga_dash_access_back']) and 1 == $GADASH_Config->options['dashboard_widget']) {
         wp_add_dashboard_widget('gadash-widget', __("Google Analytics Dashboard", 'ga-dash'), array($this, 'dashboard_widget'), $control_callback = null);
     }
 }
Example #5
0
function gadash_init()
{
    global $GADASH_Config;
    /*
     * Include Tools
     */
    include_once $GADASH_Config->plugin_path . '/tools/tools.php';
    $tools = new GADASH_Tools();
    if (is_admin()) {
        /*
         * Include backend widgets
         */
        if ($tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
            include_once dirname(__FILE__) . '/admin/dashboard_widgets.php';
        }
    } else {
        /*
         * Include frontend stats
         */
        if ($tools->check_roles($GADASH_Config->options['ga_dash_access_front']) and ($GADASH_Config->options['ga_dash_frontend_stats'] or $GADASH_Config->options['ga_dash_frontend_keywords'])) {
            include_once dirname(__FILE__) . '/front/frontend.php';
        }
        /*
         * Include tracking
         */
        if (!$tools->check_roles($GADASH_Config->options['ga_track_exclude'], true) and $GADASH_Config->options['ga_dash_tracking']) {
            include_once dirname(__FILE__) . '/front/tracking.php';
        }
    }
    /*
     * Include frontend widgets
     */
    include_once dirname(__FILE__) . '/front/widgets.php';
    /*
     * Include Frontend Ajax actions
     */
    include_once $GADASH_Config->plugin_path . '/front/ajax-actions.php';
    /*
     * Include Backend Ajax actions
     */
    include_once $GADASH_Config->plugin_path . '/admin/ajax-actions.php';
}
Example #6
0
 /**
  * Ajax handler for getting analytics data for frontend Views vs UniqueViews
  *
  * @return string|int
  */
 function ajax_afterpost_reports()
 {
     global $GADASH_Config;
     $page_url = esc_url($_REQUEST['gadash_pageurl']);
     $post_id = (int) $_REQUEST['gadash_postid'];
     $query = $_REQUEST['query'];
     ob_clean();
     if (!isset($_REQUEST['gadash_security_pagereports']) or !wp_verify_nonce($_REQUEST['gadash_security_pagereports'], 'gadash_get_frontend_pagereports')) {
         print json_encode(-30);
         die;
     }
     /*
      * Include Tools
      */
     include_once $GADASH_Config->plugin_path . '/tools/tools.php';
     $tools = new GADASH_Tools();
     if (!$tools->check_roles($GADASH_Config->options['ga_dash_access_front']) or !($GADASH_Config->options['ga_dash_frontend_stats'] or $GADASH_Config->options['ga_dash_frontend_keywords'])) {
         print json_encode(-31);
         die;
     }
     if ($GADASH_Config->options['ga_dash_token'] and $GADASH_Config->options['ga_dash_tableid_jail']) {
         include_once $GADASH_Config->plugin_path . '/tools/gapi.php';
         global $GADASH_GAPI;
     } else {
         print json_encode(-24);
         die;
     }
     $projectId = $GADASH_Config->options['ga_dash_tableid_jail'];
     $profile_info = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $projectId);
     if (isset($profile_info[4])) {
         $GADASH_GAPI->timeshift = $profile_info[4];
     } else {
         $GADASH_GAPI->timeshift = (int) current_time('timestamp') - time();
     }
     if (!$GADASH_GAPI->client->getAccessToken()) {
         print json_encode(-25);
         die;
     }
     switch ($query) {
         case 'pageviews':
             print $GADASH_GAPI->frontend_afterpost_pageviews($projectId, $page_url, $post_id);
             break;
         default:
             print $GADASH_GAPI->frontend_afterpost_searches($projectId, $page_url, $post_id);
             break;
     }
     die;
 }
 function __construct()
 {
     global $GADASH_Config;
     $tools = new GADASH_Tools();
     if (!$tools->check_roles($GADASH_Config->options['ga_dash_access_back']) or 0 == $GADASH_Config->options['item_reports']) {
         return;
     }
     // Add custom column in Posts List
     add_filter('manage_posts_columns', array($this, 'add_stats_column'));
     // Populate custom column in Posts List
     add_action('manage_posts_custom_column', array($this, 'display_item_stats'), 10, 2);
     // Add custom column in Pages List
     add_filter('manage_pages_columns', array($this, 'add_stats_column'));
     // Populate custom column in Pages List
     add_action('manage_pages_custom_column', array($this, 'display_item_stats'), 10, 2);
 }
Example #8
0
 function ga_dash_tracking($head)
 {
     global $GADASH_Config;
     /*
      * Include Tools
      */
     include_once $GADASH_Config->plugin_path . '/tools/tools.php';
     $tools = new GADASH_Tools();
     if ($tools->check_roles($GADASH_Config->options['ga_track_exclude'], true)) {
         return;
     }
     $traking_mode = $GADASH_Config->options['ga_dash_tracking'];
     $traking_type = $GADASH_Config->options['ga_dash_tracking_type'];
     if ($traking_mode == 1 or $traking_mode == 2 and !$GADASH_Config->options['ga_tracking_code']) {
         if (!$GADASH_Config->options['ga_dash_tableid_jail']) {
             return;
         }
         if ($traking_type == "universal") {
             echo "\n<!-- BEGIN GADWP Universal Tracking - http://deconf.com/google-analytics-dashboard-wordpress/ -->\n";
             if ($GADASH_Config->options['ga_event_tracking']) {
                 require_once 'tracking/events-universal.php';
             }
             require_once 'tracking/code-universal.php';
             echo "\n<!-- END GADWP Universal Tracking -->\n\n";
         } else {
             echo "\n<!-- BEGIN GADWP Classic Tracking - http://deconf.com/google-analytics-dashboard-wordpress/ -->\n";
             if ($GADASH_Config->options['ga_event_tracking']) {
                 require_once 'tracking/events-classic.php';
             }
             require_once 'tracking/code-classic.php';
             echo "\n<!-- END GADWP Classic Tracking -->\n\n";
         }
     } else {
         if ($GADASH_Config->options['ga_tracking_code']) {
             echo "\n<!-- BEGIN GADWP Custom Tracking - http://deconf.com/google-analytics-dashboard-wordpress/ -->\n";
             if ($GADASH_Config->options['ga_event_tracking']) {
                 if (strpos($GADASH_Config->options['ga_tracking_code'], 'analytics.js')) {
                     require_once 'tracking/events-universal.php';
                 } else {
                     require_once 'tracking/events-classic.php';
                 }
             }
             echo "\n" . stripslashes($GADASH_Config->options['ga_tracking_code']) . "\n";
             echo "\n<!-- END GADWP Custom Tracking -->\n\n";
         }
     }
 }
 /**
  * Ajax handler for getting realtime analytics data for Admin widget
  *
  * @return string|int
  */
 function ajax_adminwidget_realtime()
 {
     global $GADASH_Config;
     if (!isset($_REQUEST['gadashadmin_security_widgetrealtime']) or !wp_verify_nonce($_REQUEST['gadashadmin_security_widgetrealtime'], 'gadashadmin_get_realtime')) {
         wp_die(-30);
     }
     $projectId = $_REQUEST['projectId'];
     if (ob_get_length()) {
         ob_clean();
     }
     /*
      * Include Tools
      */
     include_once $GADASH_Config->plugin_path . '/tools/tools.php';
     $tools = new GADASH_Tools();
     if (!$tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
         wp_die(-31);
     }
     if ($GADASH_Config->options['ga_dash_token'] and $projectId) {
         include_once $GADASH_Config->plugin_path . '/tools/gapi.php';
         global $GADASH_GAPI;
     } else {
         wp_die(-24);
     }
     $this->send_json($GADASH_GAPI->gadash_realtime_data($projectId));
 }
        function ga_dash_front_content($content)
        {
            global $post;
            global $GADASH_Config;
            /*
             * Include Tools
             */
            include_once $GADASH_Config->plugin_path . '/tools/tools.php';
            $tools = new GADASH_Tools();
            if (!$tools->check_roles($GADASH_Config->options['ga_dash_access_front']) or !($GADASH_Config->options['ga_dash_frontend_stats'] or $GADASH_Config->options['ga_dash_frontend_keywords'])) {
                return $content;
            }
            if ((is_page() || is_single()) && !is_preview()) {
                wp_enqueue_script('gadash-general-settings', plugins_url('admin/js/admin.js', dirname(__FILE__)), array('jquery'));
                $page_url = $_SERVER["REQUEST_URI"];
                // str_replace(site_url(), "", get_permalink());
                $post_id = $post->ID;
                $content .= '<script type="text/javascript">
                  
                  gadash_firstclick = true;
                    
                  function checknpcounter(max) {
                    	try {
                    		if (npcounter == max) {
                    			NProgress.done();
                    		} else {
                    			npcounter++;
                    			NProgress.set((1/(max+1))*npcounter);
                    		}
                    	} catch(e) {}		
                    }

                    npcounter = 0;
                    
					jQuery(document).ready(function(){
					 	jQuery("#gadwp-title").click(function(){
							  	if (gadash_firstclick){
                                        
                                	try {
                                    	NProgress.configure({ parent: "#gadwp-progressbar" });
                                        NProgress.configure({ showSpinner: false });
                                        NProgress.start();
                                	} catch(e) {
                                		jQuery("#gadwp-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red","font-size":"13px"});
                                		jQuery("#gadwp-progressbar").html("' . __("A JavaScript Error is blocking plugin resources!", 'ga-dash') . '");
                                	} 
                                		    
									if(typeof ga_dash_drawpagesessions == "function"){
										jQuery.post("' . admin_url('admin-ajax.php') . '", {action: "gadash_get_frontend_pagereports",gadash_pageurl: "' . $page_url . '",gadash_postid: "' . $post_id . '",query: "pageviews",gadash_security_pagereports: "' . wp_create_nonce('gadash_get_frontend_pagereports') . '"}, function(response){
										  if (!jQuery.isNumeric(response)){  
                                            if (jQuery.isArray(response)){
                                            	gadash_pagesessions = response;
                                       		    google.setOnLoadCallback(ga_dash_drawpagesessions(gadash_pagesessions));
                                             } else {
                                             	checknpcounter(0);
                                     			jQuery("#gadwp-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red","font-size":"13px"});
                                     			jQuery("#gadwp-progressbar").html("' . __("Invalid response, more details in JavaScript Console (F12).", 'ga-dash') . '");
                                     			console.log("\\n********************* GADWP Log ********************* \\n\\n"+response);
                                     		} 										  
										  }else{
									        jQuery("#gadwp-sessions").css({"background-color":"#F7F7F7","height":"auto","padding-top":"30px","padding-bottom":"30px","color":"#000","text-align":"center"});  
									        jQuery("#gadwp-sessions").html("' . __("This report is unavailable", 'ga-dash') . ' ("+response+")");
									        checknpcounter(1);    
                                          }	
										});
									}
									if(typeof ga_dash_drawpagesearches == "function"){
										jQuery.post("' . admin_url('admin-ajax.php') . '", {action: "gadash_get_frontend_pagereports",gadash_pageurl: "' . $page_url . '",gadash_postid: "' . $post_id . '",query: "searches",gadash_security_pagereports: "' . wp_create_nonce('gadash_get_frontend_pagereports') . '"}, function(response){
                                            if (!jQuery.isNumeric(response)){										  
                                              if (jQuery.isArray(response)){
                                                  gadash_pagesearches = response;
                                           		  google.setOnLoadCallback(ga_dash_drawpagesearches(gadash_pagesearches));
                                               } else {
                                                  checknpcounter(0);
                                         		  jQuery("#gadwp-progressbar").css({"margin-top":"3px","padding-left":"5px","height":"auto","color":"#000","border-left":"5px solid red","font-size":"13px"});
                                         		  jQuery("#gadwp-progressbar").html("' . __("Invalid response, more details in JavaScript Console (F12).", 'ga-dash') . '");
                                         		  console.log("\\n********************* GADWP Log ********************* \\n\\n"+response);
                                       		   }										    
											}else{
										        jQuery("#gadwp-searches").css({"background-color":"#F7F7F7","height":"auto","padding-top":"30px","padding-bottom":"30px","color":"#000","text-align":"center"});
										        jQuery("#gadwp-searches").html("' . __("This report is unavailable", 'ga-dash') . ' ("+response+")");
										        checknpcounter(1);
                                            }	
										});
									}
    							gadash_firstclick = false;
							}
						});
					});';
                if ($GADASH_Config->options['ga_dash_frontend_stats']) {
                    $title = __("Views vs UniqueViews", 'ga-dash');
                    if (isset($GADASH_Config->options['ga_dash_style'])) {
                        $css = "colors:['" . $GADASH_Config->options['ga_dash_style'] . "','" . $tools->colourVariator($GADASH_Config->options['ga_dash_style'], -20) . "'],";
                        $color = $GADASH_Config->options['ga_dash_style'];
                    } else {
                        $css = "";
                        $color = "#3366CC";
                    }
                    $content .= '
			google.load("visualization", "1", {packages:["corechart"]});
			function ga_dash_drawpagesessions(gadash_pagesessions) {
	
			var data = google.visualization.arrayToDataTable(gadash_pagesessions);

			var options = {
			  legend: {position: "none"},
			  pointSize: 3,' . $css . '
			  title: "' . $title . '",
	  		  vAxis: { textPosition: "in", minValue: 0},
			  chartArea: {width: "100%", height: "80%"},
			  hAxis: { textPosition: "none"}
			};

			var chart = new google.visualization.AreaChart(document.getElementById("gadwp-sessions"));
			chart.draw(data, options);
            checknpcounter(1);      
			}';
                }
                if ($GADASH_Config->options['ga_dash_frontend_keywords']) {
                    $content .= '
				google.load("visualization", "1", {packages:["table"]})
				function ga_dash_drawpagesearches(gadash_pagesearches) {

				var datas = google.visualization.arrayToDataTable(gadash_pagesearches);

				var options = {
					page: "enable",
					pageSize: 6,
					width: "100%"
				};

				var chart = new google.visualization.Table(document.getElementById("gadwp-searches"));
				chart.draw(datas, options);
				checknpcounter(1);
			  }';
                }
                $content .= "</script>";
                $content .= '<p>
								<div id="gadwp">
									<div id="gadwp-title">
									<a href="#gadwp">' . __('Google Analytics Reports', "ga-dash") . ' <span id="gadwp-arrow">&#x25BC;</span></a>
									</div>
									<div id="gadwp-progressbar"></div>    
									<div id="gadwp-content">
										' . ($GADASH_Config->options['ga_dash_frontend_stats'] ? '<div id="gadwp-sessions"></div>' : '') . ($GADASH_Config->options['ga_dash_frontend_keywords'] ? '<div id="gadwp-searches" class="gadwp-spinner"></div>' : '') . '
									</div>
								</div>
							</p>';
            }
            return $content;
        }
Example #11
0
 function ga_dash_setup()
 {
     global $GADASH_Config;
     /*
      * Include Tools
      */
     include_once $GADASH_Config->plugin_path . '/tools/tools.php';
     $tools = new GADASH_Tools();
     if ($tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
         wp_add_dashboard_widget('gadash-widget', __("Google Analytics Dashboard", 'ga-dash'), array($this, 'gadash_dashboard_widgets'), $control_callback = null);
     }
 }
Example #12
0
        function ga_dash_front_content($content)
        {
            global $post;
            global $GADASH_Config;
            /*
             * Include Tools
             */
            include_once $GADASH_Config->plugin_path . '/tools/tools.php';
            $tools = new GADASH_Tools();
            if (!$tools->check_roles($GADASH_Config->options['ga_dash_access_front']) or !($GADASH_Config->options['ga_dash_frontend_stats'] or $GADASH_Config->options['ga_dash_frontend_keywords'])) {
                return $content;
            }
            if ((is_page() || is_single()) && !is_preview()) {
                /*
                 * Include GAPI
                 */
                if (function_exists('curl_version') and $GADASH_Config->options['ga_dash_tableid_jail'] and $GADASH_Config->options['ga_dash_token']) {
                    include_once $GADASH_Config->plugin_path . '/tools/gapi.php';
                    global $GADASH_GAPI;
                } else {
                    return $content;
                }
                if (!$GADASH_GAPI->client->getAccessToken()) {
                    return $content;
                }
                if (isset($GADASH_Config->options['ga_dash_tableid_jail'])) {
                    $projectId = $GADASH_Config->options['ga_dash_tableid_jail'];
                    $profile_info = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $projectId);
                    if (isset($profile_info[4])) {
                        $GADASH_GAPI->timeshift = $profile_info[4];
                    } else {
                        $GADASH_GAPI->timeshift = (int) current_time('timestamp') - time();
                    }
                } else {
                    return $content;
                }
                $page_url = $_SERVER["REQUEST_URI"];
                // str_replace(site_url(), "", get_permalink());
                $post_id = $post->ID;
                $data_visits = $GADASH_GAPI->frontend_afterpost_visits($projectId, $page_url, $post_id);
                $data_keywords = $GADASH_GAPI->frontend_afterpost_searches($projectId, $page_url, $post_id);
                if ($data_visits or $data_keywords) {
                    $content .= '<style>
				#ga_dash_sdata td{
					line-height:1.5em;
					padding:2px;
					font-size:1em;
				}
				#ga_dash_sdata{
					line-height:10px;
				}
				</style>';
                    $content .= '<script type="text/javascript" src="https://www.google.com/jsapi"></script>
				<script type="text/javascript">
				  google.setOnLoadCallback(ga_dash_callback);
				
				  function ga_dash_callback(){
						
						if(typeof ga_dash_drawstats == "function"){
							ga_dash_drawstats();
						}
						if(typeof ga_dash_drawsd == "function"){
							ga_dash_drawsd();
						}
				}';
                    if ($GADASH_Config->options['ga_dash_frontend_stats']) {
                        $content .= $data_visits;
                    }
                    if ($GADASH_Config->options['ga_dash_frontend_keywords']) {
                        $content .= $data_keywords;
                    }
                    $content .= "</script>";
                    $content .= '<p><div id="ga_dash_statsdata"></div><div id="ga_dash_sdata" ></div></p>';
                }
            }
            return $content;
        }
        function gadash_dashboard_widgets()
        {
            global $GADASH_Config;
            /*
             * Include GAPI
             */
            if ($GADASH_Config->options['ga_dash_token'] and function_exists('curl_version')) {
                include_once $GADASH_Config->plugin_path . '/tools/gapi.php';
                global $GADASH_GAPI;
            } else {
                echo '<p>' . __("This plugin needs an authorization:", 'ga-dash') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Authorize Plugin", 'ga-dash'), 'secondary') . '</form>';
                return;
            }
            /*
             * Include Tools
             */
            include_once $GADASH_Config->plugin_path . '/tools/tools.php';
            $tools = new GADASH_Tools();
            $tools->ga_dash_cleanup_timeouts();
            if (!$GADASH_GAPI->client->getAccessToken()) {
                echo '<p>' . __("Something went wrong. Please check the Debugging Data section for possible errors", 'ga-dash') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Error Log", 'ga-dash'), 'secondary') . '</form>';
                return;
            }
            if (current_user_can('manage_options')) {
                if (isset($_REQUEST['ga_dash_profile_select'])) {
                    $GADASH_Config->options['ga_dash_tableid'] = $_REQUEST['ga_dash_profile_select'];
                }
                $profiles = $GADASH_Config->options['ga_dash_profile_list'];
                $profile_switch = '';
                if (is_array($profiles)) {
                    if (!$GADASH_Config->options['ga_dash_tableid']) {
                        if ($GADASH_Config->options['ga_dash_tableid_jail']) {
                            $GADASH_Config->options['ga_dash_tableid'] = $GADASH_Config->options['ga_dash_tableid_jail'];
                        } else {
                            $GADASH_Config->options['ga_dash_tableid'] = $tools->guess_default_domain($profiles);
                        }
                    } else {
                        if ($GADASH_Config->options['ga_dash_jailadmins'] and $GADASH_Config->options['ga_dash_tableid_jail']) {
                            $GADASH_Config->options['ga_dash_tableid'] = $GADASH_Config->options['ga_dash_tableid_jail'];
                        }
                    }
                    $profile_switch .= '<select id="ga_dash_profile_select" name="ga_dash_profile_select" onchange="this.form.submit()">';
                    foreach ($profiles as $profile) {
                        if (!$GADASH_Config->options['ga_dash_tableid']) {
                            $GADASH_Config->options['ga_dash_tableid'] = $profile[1];
                        }
                        if (isset($profile[3])) {
                            $profile_switch .= '<option value="' . esc_attr($profile[1]) . '" ';
                            $profile_switch .= selected($profile[1], $GADASH_Config->options['ga_dash_tableid'], false);
                            $profile_switch .= ' title="' . __("View Name:", 'ga-dash') . ' ' . esc_attr($profile[0]) . '">' . esc_attr($tools->ga_dash_get_profile_domain($profile[3])) . '</option>';
                        }
                    }
                    $profile_switch .= "</select>";
                } else {
                    echo '<p>' . __("Something went wrong while retrieving profiles list.", 'ga-dash') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("More details", 'ga-dash'), 'secondary') . '</form>';
                    return;
                }
            }
            $GADASH_Config->set_plugin_options();
            ?>
<form id="ga-dash" method="POST">
						<?php 
            if (current_user_can('manage_options')) {
                if ($GADASH_Config->options['ga_dash_jailadmins']) {
                    if ($GADASH_Config->options['ga_dash_tableid_jail']) {
                        $projectId = $GADASH_Config->options['ga_dash_tableid_jail'];
                    } else {
                        echo '<p>' . __("An admin should asign a default Google Analytics Profile.", 'ga-dash') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Select Domain", 'ga-dash'), 'secondary') . '</form>';
                        return;
                    }
                } else {
                    echo $profile_switch;
                    $projectId = $GADASH_Config->options['ga_dash_tableid'];
                }
            } else {
                if ($GADASH_Config->options['ga_dash_tableid_jail']) {
                    $projectId = $GADASH_Config->options['ga_dash_tableid_jail'];
                } else {
                    echo '<p>' . __("An admin should asign a default Google Analytics Profile.", 'ga-dash') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Select Domain", 'ga-dash'), 'secondary') . '</form>';
                    return;
                }
            }
            if (!$projectId) {
                echo '<p>' . __("Something went wrong while retrieving property data. You need to create and properly configure a Google Analytics account:", 'ga-dash') . '</p> <form action="https://deconf.com/how-to-set-up-google-analytics-on-your-website/" method="POST">' . get_submit_button(__("Find out more!", 'ga-dash'), 'secondary') . '</form>';
                return;
            } else {
                $profile_info = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $projectId);
                if (isset($profile_info[4])) {
                    $GADASH_GAPI->timeshift = $profile_info[4];
                } else {
                    $GADASH_GAPI->timeshift = (int) current_time('timestamp') - time();
                }
            }
            if (isset($_REQUEST['query'])) {
                $query = $_REQUEST['query'];
                $GADASH_Config->options['ga_dash_default_metric'] = $query;
                $GADASH_Config->set_plugin_options();
            } else {
                $query = isset($GADASH_Config->options['ga_dash_default_metric']) ? $GADASH_Config->options['ga_dash_default_metric'] : 'visits';
            }
            if (isset($_REQUEST['period'])) {
                $period = $_REQUEST['period'];
                $GADASH_Config->options['ga_dash_default_dimension'] = $period;
                $GADASH_Config->set_plugin_options();
            } else {
                $period = isset($GADASH_Config->options['ga_dash_default_dimension']) ? $GADASH_Config->options['ga_dash_default_dimension'] : '30daysAgo';
            }
            if ($period == "realtime") {
                $realtime = "realtime";
                $period = '';
            } else {
                $realtime = '';
            }
            ?>
			
				<select id="ga_dash_period" name="period"
		onchange="this.form.submit()">
		<option value="realtime"
			<?php 
            selected("realtime", $period, true);
            ?>
><?php 
            _e("Real-Time", 'ga-dash');
            ?>
</option>
		<option value="today" <?php 
            selected("today", $period, true);
            ?>
><?php 
            _e("Today", 'ga-dash');
            ?>
</option>
		<option value="yesterday"
			<?php 
            selected("yesterday", $period, true);
            ?>
><?php 
            _e("Yesterday", 'ga-dash');
            ?>
</option>
		<option value="7daysAgo"
			<?php 
            selected("7daysAgo", $period, true);
            ?>
><?php 
            _e("Last 7 Days", 'ga-dash');
            ?>
</option>
		<option value="14daysAgo"
			<?php 
            selected("14daysAgo", $period, true);
            ?>
><?php 
            _e("Last 14 Days", 'ga-dash');
            ?>
</option>
		<option value="30daysAgo"
			<?php 
            selected("30daysAgo", $period, true);
            ?>
><?php 
            _e("Last 30 Days", 'ga-dash');
            ?>
</option>
		<option value="90daysAgo"
			<?php 
            selected("90daysAgo", $period, true);
            ?>
><?php 
            _e("Last 90 Days", 'ga-dash');
            ?>
</option>
	</select>
				<?php 
            if (!$realtime) {
                ?>
				<select id="ga_dash_query" name="query"
		onchange="this.form.submit()">
		<option value="visits" <?php 
                selected("visits", $query, true);
                ?>
><?php 
                _e("Visits", 'ga-dash');
                ?>
</option>
		<option value="visitors"
			<?php 
                selected("visitors", $query, true);
                ?>
><?php 
                _e("Visitors", 'ga-dash');
                ?>
</option>
		<option value="organicSearches"
			<?php 
                selected("organicSearches", $query, true);
                ?>
><?php 
                _e("Organic", 'ga-dash');
                ?>
</option>
		<option value="pageviews"
			<?php 
                selected("pageviews", $query, true);
                ?>
><?php 
                _e("Page Views", 'ga-dash');
                ?>
</option>
		<option value="visitBounceRate"
			<?php 
                selected("visitBounceRate", $query, true);
                ?>
><?php 
                _e("Bounce Rate", 'ga-dash');
                ?>
</option>
	</select> 	
				<?php 
            }
            ?>
			</form>
<?php 
            switch ($period) {
                case 'today':
                    $from = 'today';
                    $to = 'today';
                    $haxis = 4;
                    $dh = __("Hour", 'ga-dash');
                    break;
                case 'yesterday':
                    $from = 'yesterday';
                    $to = 'yesterday';
                    $haxis = 4;
                    $dh = __("Hour", 'ga-dash');
                    break;
                case '7daysAgo':
                    $from = '7daysAgo';
                    $to = 'yesterday';
                    $haxis = 2;
                    $dh = __("Date", 'ga-dash');
                    break;
                case '14daysAgo':
                    $from = '14daysAgo';
                    $to = 'yesterday';
                    $haxis = 3;
                    $dh = __("Date", 'ga-dash');
                    break;
                case '30daysAgo':
                    $from = '30daysAgo';
                    $to = 'yesterday';
                    $haxis = 5;
                    $dh = __("Date", 'ga-dash');
                    break;
                default:
                    $from = '90daysAgo';
                    $to = 'yesterday';
                    $haxis = 16;
                    $dh = __("Date", 'ga-dash');
                    break;
            }
            if ($realtime == "realtime") {
                wp_register_style('jquery-ui-tooltip-html', $GADASH_Config->plugin_url . '/realtime/jquery/jquery.ui.tooltip.html.css');
                wp_enqueue_style('jquery-ui-tooltip-html');
                if (!wp_script_is('jquery')) {
                    wp_enqueue_script('jquery');
                }
                if (!wp_script_is('jquery-ui-tooltip')) {
                    wp_enqueue_script("jquery-ui-tooltip");
                }
                if (!wp_script_is('jquery-ui-core')) {
                    wp_enqueue_script("jquery-ui-core");
                }
                if (!wp_script_is('jquery-ui-position')) {
                    wp_enqueue_script("jquery-ui-position");
                }
                if (!wp_script_is('jquery-ui-position')) {
                    wp_enqueue_script("jquery-ui-position");
                }
                wp_register_script("jquery-ui-tooltip-html", $GADASH_Config->plugin_url . '/realtime/jquery/jquery.ui.tooltip.html.js');
                wp_enqueue_script("jquery-ui-tooltip-html");
            } else {
                switch ($query) {
                    case 'visitors':
                        $title = __("Visitors", 'ga-dash');
                        break;
                    case 'pageviews':
                        $title = __("Page Views", 'ga-dash');
                        break;
                    case 'visitBounceRate':
                        $title = __("Bounce Rate", 'ga-dash');
                        break;
                    case 'organicSearches':
                        $title = __("Organic Searches", 'ga-dash');
                        break;
                    default:
                        $title = __("Visits", 'ga-dash');
                }
            }
            if ($query == 'visitBounceRate') {
                $formater = "var formatter = new google.visualization.NumberFormat({\r\n\t\t\t\t  pattern: '#,##%',\r\n\t\t\t\t  fractionDigits: 2\r\n\t\t\t\t});\r\n\t\t\t\r\n\t\t\t\tformatter.format(data, 1);\t";
            } else {
                $formater = '';
            }
            $ga_dash_statsdata = $GADASH_GAPI->ga_dash_main_charts($projectId, $period, $from, $to, $query);
            if (!$ga_dash_statsdata) {
                echo '<p>' . __("No stats available. Please check the Debugging Data section for possible errors", 'ga-dash') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Error Log", 'ga-dash'), 'secondary') . '</form>';
                return;
            }
            $ga_dash_bottom_stats = $GADASH_GAPI->ga_dash_bottom_stats($projectId, $period, $from, $to);
            if (!$ga_dash_bottom_stats) {
                echo '<p>' . __("No stats available. Please check the Debugging Data section for possible errors", 'ga-dash') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Error Log", 'ga-dash'), 'secondary') . '</form>';
                return;
            }
            if (isset($GADASH_Config->options['ga_dash_style'])) {
                $light_color = $tools->colourVariator($GADASH_Config->options['ga_dash_style'], 40);
                $dark_color = $tools->colourVariator($GADASH_Config->options['ga_dash_style'], -20);
                $css = "colors:['" . $GADASH_Config->options['ga_dash_style'] . "','" . $tools->colourVariator($GADASH_Config->options['ga_dash_style'], -20) . "'],";
                $color = $GADASH_Config->options['ga_dash_style'];
            } else {
                $css = "";
                $color = "#3366CC";
            }
            ?>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
		      google.load("visualization", "1", {packages:["corechart"]});
		      google.setOnLoadCallback(ga_dash_callback);
				
			  function ga_dash_callback(){
					if(typeof ga_dash_drawstats == "function"){
						ga_dash_drawstats();
					}
					if(typeof ga_dash_drawmap == "function"){
						ga_dash_drawmap();
					}
					if(typeof ga_dash_drawpgd == "function"){
						ga_dash_drawpgd();
					}
					if(typeof ga_dash_drawrd == "function"){
						ga_dash_drawrd();
					}
					if(typeof ga_dash_drawsd == "function"){
						ga_dash_drawsd();
					}
					if(typeof ga_dash_drawtraffic == "function"){
						ga_dash_drawtraffic();
					}
			  };
			  
			<?php 
            if ($realtime != "realtime") {
                ?>
					
				function ga_dash_drawstats() {
		        var data = google.visualization.arrayToDataTable([
		          ['<?php 
                echo $dh;
                ?>
', '<?php 
                echo $title;
                ?>
'], <?php 
                echo $ga_dash_statsdata;
                ?>
]);
				
		        var options = {
				  legend: {position: 'none'},
				  pointSize: 3,<?php 
                echo $css;
                ?>
		          title: '<?php 
                echo $title;
                ?>
',
				  chartArea: {width: '85%'},
				  vAxis: {minValue: 0},
		          hAxis: { title: '<?php 
                echo $dh;
                ?>
',  titleTextStyle: {color: '<?php 
                echo $dark_color;
                ?>
'}, showTextEvery: <?php 
                echo $haxis;
                ?>
}
				};
				<?php 
                echo $formater;
                ?>
		        var chart = new google.visualization.AreaChart(document.getElementById('ga_dash_statsdata'));
				chart.draw(data, options);
	      		};
	      		
	      	<?php 
            }
            $ga_dash_visits_country = '';
            if ($GADASH_Config->options['ga_dash_map'] and $tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
                $ga_dash_visits_country = $GADASH_GAPI->ga_dash_visits_country($projectId, $from, $to);
                if ($ga_dash_visits_country) {
                    ?>
		
					google.load("visualization", "1", {packages:["geochart"]})
					function ga_dash_drawmap() {
						var data = google.visualization.arrayToDataTable([
						  ['<?php 
                    _e("Country/City", 'ga-dash');
                    ?>
', ' <?php 
                    _e("Visits", 'ga-dash');
                    ?>
'], <?php 
                    echo $ga_dash_visits_country;
                    ?>
						]);
					
						var options = {
							colors: ['<?php 
                    echo $light_color;
                    ?>
', '<?php 
                    echo $dark_color;
                    ?>
'],
							<?php 
                    if ($GADASH_Config->options['ga_target_geomap']) {
                        ?>
								region : '<?php 
                        echo esc_html($GADASH_Config->options['ga_target_geomap']);
                        ?>
',
								displayMode : 'markers',
								datalessRegionColor : 'EFEFEF'
							<?php 
                    }
                    ?>
		
							}
						var chart = new google.visualization.GeoChart(document.getElementById('ga_dash_mapdata'));
						chart.draw(data, options);
					}
				<?php 
                }
            }
            $ga_dash_traffic_sources = '';
            $ga_dash_new_return = '';
            if ($GADASH_Config->options['ga_dash_traffic'] and $tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
                $ga_dash_traffic_sources = $GADASH_GAPI->ga_dash_traffic_sources($projectId, $from, $to);
                $ga_dash_new_return = $GADASH_GAPI->ga_dash_new_return($projectId, $from, $to);
                if ($ga_dash_traffic_sources and $ga_dash_new_return) {
                    ?>
					google.load("visualization", "1", {packages:["corechart"]})
					function ga_dash_drawtraffic() {
						var data = google.visualization.arrayToDataTable([
						  ['<?php 
                    _e("Source", 'ga-dash');
                    ?>
', '<?php 
                    _e("Visits", 'ga-dash');
                    ?>
'], <?php 
                    echo $ga_dash_traffic_sources;
                    ?>
 ]);
		
						var datanvr = google.visualization.arrayToDataTable([
						  ['<?php 
                    echo _e("Type", 'ga-dash');
                    ?>
', '<?php 
                    _e("Visits", 'ga-dash');
                    ?>
'], <?php 
                    echo $ga_dash_new_return;
                    ?>
 
						]);
		
						var chart = new google.visualization.PieChart(document.getElementById('ga_dash_trafficdata'));
						chart.draw(data, {
							is3D: false,
							tooltipText: 'percentage',
							legend: 'none',
							title: '<?php 
                    _e("Traffic Sources", 'ga-dash');
                    ?>
',
							colors:['<?php 
                    echo esc_html($GADASH_Config->options['ga_dash_style']);
                    ?>
','<?php 
                    echo esc_html($tools->colourVariator($GADASH_Config->options['ga_dash_style'], -10));
                    ?>
','<?php 
                    echo esc_html($tools->colourVariator($GADASH_Config->options['ga_dash_style'], +20));
                    ?>
','<?php 
                    echo esc_html($tools->colourVariator($GADASH_Config->options['ga_dash_style'], +10));
                    ?>
','<?php 
                    echo esc_html($tools->colourVariator($GADASH_Config->options['ga_dash_style'], -20));
                    ?>
']
						});
		
						var chart1 = new google.visualization.PieChart(document.getElementById('ga_dash_nvrdata'));
						chart1.draw(datanvr,  {
							is3D: false,
							tooltipText: 'percentage',
							legend: 'none',
							title: '<?php 
                    _e("New vs. Returning", 'ga-dash');
                    ?>
',
							colors:['<?php 
                    echo esc_html($GADASH_Config->options['ga_dash_style']);
                    ?>
','<?php 
                    echo esc_html($tools->colourVariator($GADASH_Config->options['ga_dash_style'], -10));
                    ?>
','<?php 
                    echo esc_html($tools->colourVariator($GADASH_Config->options['ga_dash_style'], +20));
                    ?>
','<?php 
                    echo esc_html($tools->colourVariator($GADASH_Config->options['ga_dash_style'], +10));
                    ?>
','<?php 
                    echo esc_html($tools->colourVariator($GADASH_Config->options['ga_dash_style'], -20));
                    ?>
']				
						});
		
		  			}
		  		<?php 
                }
            }
            $ga_dash_top_pages = '';
            if ($GADASH_Config->options['ga_dash_pgd'] and $tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
                $ga_dash_top_pages = $GADASH_GAPI->ga_dash_top_pages($projectId, $from, $to);
                if ($ga_dash_top_pages) {
                    ?>
					google.load("visualization", "1", {packages:["table"]})
					function ga_dash_drawpgd() {
					var data = google.visualization.arrayToDataTable([
					  ['<?php 
                    _e("Top Pages", 'ga-dash');
                    ?>
', '<?php 
                    _e("Visits", 'ga-dash');
                    ?>
'], <?php 
                    echo $ga_dash_top_pages;
                    ?>
					]);
		
					var options = {
						page: 'enable',
						pageSize: 6,
						width: '100%',
						allowHtml:true			
					};
		
					var chart = new google.visualization.Table(document.getElementById('ga_dash_pgddata'));
					chart.draw(data, options);
		
					};
				<?php 
                }
            }
            $ga_dash_top_referrers = '';
            if ($GADASH_Config->options['ga_dash_rd'] and $tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
                $ga_dash_top_referrers = $GADASH_GAPI->ga_dash_top_referrers($projectId, $from, $to);
                if ($ga_dash_top_referrers) {
                    ?>
					google.load("visualization", "1", {packages:["table"]})
					function ga_dash_drawrd() {
						var datar = google.visualization.arrayToDataTable([
				  			['<?php 
                    _e("Top Referrers", 'ga-dash');
                    ?>
', '<?php 
                    _e("Visits", 'ga-dash');
                    ?>
'], <?php 
                    echo $ga_dash_top_referrers;
                    ?>
						]);
			
						var options = {
							page: 'enable',
							pageSize: 6,
							width: '100%',
							allowHtml:true	
						};
			
						var chart = new google.visualization.Table(document.getElementById('ga_dash_rdata'));
						chart.draw(datar, options);
		  			}
		  		<?php 
                }
            }
            $ga_dash_top_searches = '';
            if ($GADASH_Config->options['ga_dash_sd'] and $tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
                $ga_dash_top_searches = $GADASH_GAPI->ga_dash_top_searches($projectId, $from, $to);
                if ($ga_dash_top_searches) {
                    ?>
					google.load("visualization", "1", {packages:["table"]})
					function ga_dash_drawsd() {
		
						var datas = google.visualization.arrayToDataTable([
						  ['<?php 
                    echo _e("Top Searches", 'ga-dash');
                    ?>
', '<?php 
                    _e("Visits", 'ga-dash');
                    ?>
'], <?php 
                    echo $ga_dash_top_searches;
                    ?>
						]);
					
						var options = {
							page: 'enable',
							pageSize: 6,
							width: '100%'
						};
					
						var chart = new google.visualization.Table(document.getElementById('ga_dash_sdata'));
						chart.draw(datas, options);
		
					}
				<?php 
                }
            }
            ?>
			</script>
</script>
<?php 
            if ($realtime != "realtime") {
                ?>
<div id="ga_dash_statsdata" class="widefat" style="height: 350px;"></div>
<div id="details_div">

	<table class="gatable" cellpadding="4">
		<tr>
			<td width="24%"><?php 
                _e("Visits:", 'ga-dash');
                ?>
</td>
			<td width="12%" class="gavalue"><a
				href="?query=visits&period=<?php 
                echo $period;
                ?>
" class="gatable"><?php 
                echo (int) $ga_dash_bottom_stats['rows'][0][1];
                ?>
</td>
			<td width="24%"><?php 
                _e("Visitors:", 'ga-dash');
                ?>
</td>
			<td width="12%" class="gavalue"><a
				href="?query=visitors&period=<?php 
                echo $period;
                ?>
" class="gatable"><?php 
                echo (int) $ga_dash_bottom_stats['rows'][0][2];
                ?>
</a></td>
			<td width="24%"><?php 
                _e("Page Views:", 'ga-dash');
                ?>
</td>
			<td width="12%" class="gavalue"><a
				href="?query=pageviews&period=<?php 
                echo $period;
                ?>
"
				class="gatable"><?php 
                echo (int) $ga_dash_bottom_stats['rows'][0][3];
                ?>
</a></td>
		</tr>
		<tr>
			<td><?php 
                _e("Bounce Rate:", 'ga-dash');
                ?>
</td>
			<td class="gavalue"><a
				href="?query=visitBounceRate&period=<?php 
                echo $period;
                ?>
"
				class="gatable"><?php 
                echo (double) round($ga_dash_bottom_stats['rows'][0][4], 2);
                ?>
%</a></td>
			<td><?php 
                _e("Organic Search:", 'ga-dash');
                ?>
</td>
			<td class="gavalue"><a
				href="?query=organicSearches&period=<?php 
                echo $period;
                ?>
"
				class="gatable"><?php 
                echo (int) $ga_dash_bottom_stats['rows'][0][5];
                ?>
</a></td>
			<td><?php 
                _e("Pages per Visit:", 'ga-dash');
                ?>
</td>
			<td class="gavalue"><a href="#" class="gatable"><?php 
                echo (double) ($ga_dash_bottom_stats['rows'][0][1] ? round($ga_dash_bottom_stats['rows'][0][3] / $ga_dash_bottom_stats['rows'][0][1], 2) : '0');
                ?>
</a></td>
		</tr>
	</table>

</div>
<?php 
            } else {
                if ($GADASH_Config->options['ga_dash_userapi']) {
                    ?>
<p style='padding: 100px; line-height: 2em;'> <?php 
                    _e("This is a beta feature and is only available when using my Developer Key! (", 'ga-dash');
                    ?>
 <a
		href="https://deconf.com/google-analytics-dashboard-real-time-reports/"
		target="_blank"><?php 
                    _e("more about this feature", 'ga-dash');
                    ?>
</a>)
</p>
<?php 
                } else {
                    ?>
<table width='90%' class='realtime'>
	<tr>
		<td class='gadash-tdo-left'>
			<div>
				<span class='gadash-online' id='gadash-online'>&nbsp;</span>
			</div>
		</td>
		<td class='gadash-tdo-right' id='gadash-tdo-right'><span
			class="gadash-bigtext"><?php 
                    _e("REFERRAL", 'ga-dash');
                    ?>
: 0</span><br />
		<br /> <span class="gadash-bigtext"><?php 
                    _e("ORGANIC", 'ga-dash');
                    ?>
: 0</span><br />
		<br /> <span class="gadash-bigtext"><?php 
                    _e("SOCIAL", 'ga-dash');
                    ?>
: 0</span><br />
		<br /></td>
		<td class='gadash-tdo-rights' id='gadash-tdo-rights'><span
			class="gadash-bigtext"><?php 
                    _e("DIRECT", 'ga-dash');
                    ?>
: 0</span><br />
		<br /> <span class="gadash-bigtext"><?php 
                    _e("NEW", 'ga-dash');
                    ?>
: 0</span><br />
		<br /> <span class="gadash-bigtext"><?php 
                    _e("RETURN", 'ga-dash');
                    ?>
: 0</span><br />
		<br /></td>
	</tr>
	<tr>
		<td id='gadash-pages' class='gadash-pages' colspan='3'>&nbsp;</td>
	</tr>
</table>
<?php 
                    echo $GADASH_GAPI->ga_realtime();
                }
            }
            if ($GADASH_Config->options['ga_dash_map'] and $tools->check_roles($GADASH_Config->options['ga_dash_access_back']) and $ga_dash_visits_country) {
                ?>
<br />
<h3>
				<?php 
                if ($GADASH_Config->options['ga_target_geomap']) {
                    $GADASH_GAPI->getcountrycodes();
                    echo __("Visits from ", 'ga-dash') . esc_html($GADASH_GAPI->country_codes[$GADASH_Config->options['ga_target_geomap']]);
                } else {
                    echo __("Visits by Country", 'ga-dash');
                }
                ?>
				</h3>
<div id="ga_dash_mapdata"></div>

			<?php 
            }
            if ($GADASH_Config->options['ga_dash_traffic'] and $tools->check_roles($GADASH_Config->options['ga_dash_access_back']) and ($ga_dash_top_referrers or $ga_dash_top_pages or $ga_dash_traffic_sources and $ga_dash_new_return)) {
                ?>
<br />
<h3>
				<?php 
                _e("Traffic Overview", 'ga-dash');
                ?>
				</h3>
<div style="width: 100%; clear: both;">
	<div style="width: 50%; float: left;">
		<div id="ga_dash_trafficdata"></div>
	</div>
	<div style="width: 50%; float: left;">
		<div id="ga_dash_nvrdata"></div>
	</div>
</div>
<div style="clear: both;"></div>

			<?php 
            }
            if ($GADASH_Config->options['ga_dash_pgd'] and $tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
                ?>
<div id="ga_dash_pgddata"></div>
<?php 
            }
            if ($GADASH_Config->options['ga_dash_rd'] and $tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
                ?>
<div id="ga_dash_rdata"></div>
<?php 
            }
            if ($GADASH_Config->options['ga_dash_sd'] and $tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
                ?>
<div id="ga_dash_sdata"></div>
<?php 
            }
        }
Example #14
0
 /**
  * Styles & Scripts conditional loading (based on current URI)
  *
  * @param
  *          $hook
  */
 function load_styles_scripts($hook)
 {
     global $GADASH_Config;
     $tools = new GADASH_Tools();
     /*
      * GADWP main stylesheet
      */
     wp_enqueue_style('gadwp', $GADASH_Config->plugin_url . '/admin/css/gadwp.css', NULL, GADWP_CURRENT_VERSION);
     /*
      * Dashboard Widgets Styles & Scripts
      */
     $widgets_hooks = array('index.php');
     if (in_array($hook, $widgets_hooks)) {
         wp_enqueue_style('gadwp-nprogress', $GADASH_Config->plugin_url . '/tools/nprogress/nprogress.css', NULL, GADWP_CURRENT_VERSION);
         wp_enqueue_style('gadwp-admin-widgets', $GADASH_Config->plugin_url . '/admin/css/gadwp.css', NULL, GADWP_CURRENT_VERSION);
         wp_enqueue_script('gadwp-admin-widgets', plugins_url('js/widgets.js', __FILE__), array('jquery'), GADWP_CURRENT_VERSION);
         if (!wp_script_is('googlejsapi')) {
             wp_register_script('googlejsapi', 'https://www.google.com/jsapi');
             wp_enqueue_script('googlejsapi');
         }
         wp_enqueue_script('gadwp-nprogress', $GADASH_Config->plugin_url . '/tools/nprogress/nprogress.js', array('jquery'), GADWP_CURRENT_VERSION);
     }
     /*
      * Posts/Pages List Styles & Scripts
      */
     $contentstats_hooks = array('edit.php');
     if (in_array($hook, $contentstats_hooks)) {
         if (!$tools->check_roles($GADASH_Config->options['ga_dash_access_back']) or 0 == $GADASH_Config->options['item_reports']) {
             return;
         }
         wp_enqueue_style('gadwp-nprogress', $GADASH_Config->plugin_url . '/tools/nprogress/nprogress.css', NULL, GADWP_CURRENT_VERSION);
         wp_enqueue_style('gadwp_itemreports', $GADASH_Config->plugin_url . '/admin/css/item-reports.css', NULL, GADWP_CURRENT_VERSION);
         $tools->getcountrycodes();
         if ($GADASH_Config->options['ga_target_geomap'] and isset($tools->country_codes[$GADASH_Config->options['ga_target_geomap']])) {
             $region = $GADASH_Config->options['ga_target_geomap'];
         } else {
             $region = false;
         }
         wp_enqueue_style("wp-jquery-ui-dialog");
         if (!wp_script_is('googlejsapi')) {
             wp_register_script('googlejsapi', 'https://www.google.com/jsapi');
         }
         wp_enqueue_script('gadwp-nprogress', $GADASH_Config->plugin_url . '/tools/nprogress/nprogress.js', array('jquery'), GADWP_CURRENT_VERSION);
         wp_enqueue_script('gadwp_itemreports', plugins_url('js/item-reports.js', __FILE__), array('gadwp-nprogress', 'googlejsapi', 'jquery', 'jquery-ui-dialog'), GADWP_CURRENT_VERSION);
         wp_localize_script('gadwp_itemreports', 'gadwp_item_data', array('ajaxurl' => admin_url('admin-ajax.php'), 'security' => wp_create_nonce('gadwp_get_itemreports'), 'dateList' => array('today' => __("Today", 'ga-dash'), 'yesterday' => __("Yesterday", 'ga-dash'), '7daysAgo' => __("Last 7 Days", 'ga-dash'), '30daysAgo' => __("Last 30 Days", 'ga-dash'), '90daysAgo' => __("Last 90 Days", 'ga-dash')), 'reportList' => array('uniquePageviews' => __("Unique Views", 'ga-dash'), 'users' => __("Users", 'ga-dash'), 'organicSearches' => __("Organic", 'ga-dash'), 'pageviews' => __("Page Views", 'ga-dash'), 'visitBounceRate' => __("Bounce Rate", 'ga-dash'), 'locations' => __("Location", 'ga-dash'), 'referrers' => __("Referrers", 'ga-dash'), 'searches' => __("Searches", 'ga-dash'), 'trafficdetails' => __("Traffic Details", 'ga-dash')), 'i18n' => array(__("A JavaScript Error is blocking plugin resources!", 'ga-dash'), __("Traffic Mediums", 'ga-dash'), __("Visitor Type", 'ga-dash'), __("Social Networks", 'ga-dash'), __("Search Engines", 'ga-dash'), __("Unique Views", 'ga-dash'), __("Users", 'ga-dash'), __("Page Views", 'ga-dash'), __("Bounce Rate", 'ga-dash'), __("Organic Search", 'ga-dash'), __("Pages/Session", 'ga-dash'), __("Invalid response, more details in JavaScript Console (F12).", 'ga-dash'), __("Not enough data collected", 'ga-dash'), __("This report is unavailable", 'ga-dash'), __("report generated by", 'ga-dash')), 'colorVariations' => $tools->variations($GADASH_Config->options['ga_dash_style']), 'region' => $region));
     }
     /*
      * Settings Styles & Scripts
      */
     $settings_hooks = array('toplevel_page_gadash_settings', 'google-analytics_page_gadash_backend_settings', 'google-analytics_page_gadash_frontend_settings', 'google-analytics_page_gadash_tracking_settings', 'google-analytics_page_gadash_errors_debugging');
     if (in_array($hook, $settings_hooks)) {
         wp_enqueue_style('wp-color-picker');
         wp_enqueue_script('wp-color-picker');
         wp_enqueue_script('wp-color-picker-script-handle', plugins_url('js/wp-color-picker-script.js', __FILE__), array('wp-color-picker'), false, true);
         wp_enqueue_script('gadwp-settings', plugins_url('js/settings.js', __FILE__), array('jquery'), GADWP_CURRENT_VERSION);
     }
 }