123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- if (!class_exists("plug_google_analytics")) {
- class plug_google_analytics {
- function __construct($ns) {
- $this->title = __("Google Analytics","dagsopt");
- $this->pluginname = $ns->pluginname;
- $this->file = $ns->file;
- $this->ns = $ns;
- }
- function start() {
- add_action('wp_footer',array(&$this,'footer'),100);
-
- }
- function footer() {
- $id = get_option($this->pluginname."_google_analytics_id");
- if(!empty($id)){
- ?>
- <script type="text/javascript">
- var _gaq = _gaq || [];
- _gaq.push(['_setAccount', '<?php echo($id); ?>']);
- _gaq.push(['_setDomainName', '<?php echo(get_option($this->pluginname."_google_analytics_domain")); ?>']);
- _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>
- <?php
- }
- }
-
-
- function help(){
- ?>
- <?php echo(__("Adds google analytics snippet in footer","dagsopt")) ?>
-
-
- <?php
- }
-
- function Option($pre){
- update_option ( $pre.'_id', $_POST [ $pre.'_id' ] );
- update_option ( $pre.'_domain', $_POST [ $pre.'_domain' ] );
- }
-
- function admin_line($pre){
- ?>
- <?php echo(__("Google Analytics ID:","dagsopt")) ?><br><input type="text" name="<?php echo( $pre.'_id' ); ?>" value="<?php echo(stripcslashes(get_option($pre."_id"))); ?>" > <br>
- <?php echo(__("Google Analytics Domain:","dagsopt")) ?><br><input type="text" name="<?php echo( $pre.'_domain' ); ?>" value="<?php echo(stripcslashes(get_option($pre."_domain"))); ?>" >
- <?php
- }
-
-
- }
- global $plug_google_analytics;
- $plug_google_analytics = new plug_google_analytics($this);
- $this->dagsopt['plug_google_analytics'] = $plug_google_analytics;
-
- }
|