public static function current_plugin_config($blog) { $plugindata = GoogleAnalyticsProvider::current_plugindata($blog); return $plugindata ? $plugindata->data() : null; } public static function is_ready($blog) { return GoogleAnalyticsProvider::current_plugindata($blog) ? true : false; } public function snippet($args, &$ctx) { $config = GoogleAnalyticsProvider::current_plugin_config($this->blog); if (empty($config)) { return ''; } return <<<__HTML__ <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', '{$config['profile_web_property_id']}']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> __HTML__; } } Stats::register_provider('GoogleAnalytics', 'GoogleAnalyticsProvider');