forked from q2a/question2answer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
666794b
commit 0138f69
Showing
10 changed files
with
691 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,4 @@ A clear and concise description of what you expected to happen. | |
- MySQL version: | ||
- Q2A version: | ||
- Browser: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
This plugin will add the script for Google Analytics (GA) in the <head> part of | ||
your Question2Answer installation. | ||
|
||
The only configurable part is in the "Plugins" section on the Admin interface. | ||
To start using GA, just copy your tracking code from Google Analytics and paste it in the text box. | ||
There's also possibility to disable tracking of Super Administrator's activities on the site. | ||
|
45 changes: 45 additions & 0 deletions
45
qa-plugin/QA-Google-Analytics/google-analytics-admin-form.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
class google_analytics_admin_form { | ||
|
||
function admin_form() { | ||
$saved=false; | ||
|
||
if (qa_clicked('google_analytics_save_button')) { | ||
qa_opt('google_analytics_UA', qa_post_text('google_analytics_UA_field')); | ||
qa_opt('google_analytics_show_for_admin', (bool)qa_post_text('google_analytics_show_for_admin_field')); | ||
$saved=true; | ||
} | ||
|
||
return array( | ||
'ok' => $saved ? 'Google Analytics settings saved.' : null, | ||
|
||
'fields' => array( | ||
array( | ||
'label' => 'Enter Google Analytics tracking code:', | ||
'value' => qa_opt('google_analytics_UA'), | ||
'tags' => 'NAME="google_analytics_UA_field"', | ||
'type' => 'textarea', | ||
'rows' => 10 | ||
), | ||
|
||
array( | ||
'label' => 'Check to exclude Super Admin visits from tracking.', | ||
'type' => 'checkbox', | ||
'value' => qa_opt('google_analytics_show_for_admin'), | ||
'tags' => 'NAME="google_analytics_show_for_admin_field"', | ||
), | ||
), | ||
|
||
'buttons' => array( | ||
array( | ||
'label' => 'Save Changes', | ||
'tags' => 'NAME="google_analytics_save_button"', | ||
), | ||
), | ||
|
||
); | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
class qa_html_theme_layer extends qa_html_theme_base { | ||
|
||
function head_script() {// insert Javascript into the <head> | ||
|
||
$google_UA = qa_opt('google_analytics_UA'); | ||
$google_domain = qa_opt('google_analytics_domain'); | ||
$is_admin = (qa_get_logged_in_level() == 120) ? true : false; | ||
|
||
if (!empty($google_UA)) { | ||
if (!($is_admin && qa_opt('google_analytics_show_for_admin'))) { // the loged in user is not the admin | ||
$this->content['script'][]=$google_UA; | ||
} | ||
} | ||
qa_html_theme_base::head_script(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/* | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
More about this license: http://www.question2answer.org/license.php | ||
*/ | ||
|
||
/* | ||
Plugin Name: Google Analytics | ||
Plugin URI: https://github.com/kufeiko/QA-Google-Analytics-Plugin | ||
Plugin Update Check URI: https://raw.githubusercontent.com/kufeiko/QA-Google-Analytics-Plugin/master/qa-plugin.php | ||
Plugin Description: Inserts Analytics code in the <head> and can skip for admin | ||
Plugin Version: 1.1 | ||
Plugin Date: 2015-01-27 | ||
Plugin Author: Ivan | ||
Plugin Author URI: http://patuvame.net | ||
Plugin License: GPLv2 | ||
Plugin Minimum Question2Answer Version: 1.4 | ||
*/ | ||
|
||
|
||
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser | ||
header('Location: ../../'); | ||
exit; | ||
} | ||
|
||
|
||
qa_register_plugin_layer('google-analytics-layer.php', 'Google Analytics'); | ||
qa_register_plugin_module('module', 'google-analytics-admin-form.php', 'google_analytics_admin_form', 'Google Analytics'); | ||
|
||
|
||
/* | ||
Omit PHP closing tag to help avoid accidental output | ||
*/ |
Oops, something went wrong.