Skip to content

Commit

Permalink
add plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
heshamalammar authored Jun 4, 2024
1 parent 666794b commit 0138f69
Show file tree
Hide file tree
Showing 10 changed files with 691 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ A clear and concise description of what you expected to happen.
- MySQL version:
- Q2A version:
- Browser:

7 changes: 7 additions & 0 deletions qa-plugin/QA-Google-Analytics/README
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 qa-plugin/QA-Google-Analytics/google-analytics-admin-form.php
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"',
),
),

);


}
}
18 changes: 18 additions & 0 deletions qa-plugin/QA-Google-Analytics/google-analytics-layer.php
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();
}
};
44 changes: 44 additions & 0 deletions qa-plugin/QA-Google-Analytics/qa-plugin.php
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
*/
Loading

0 comments on commit 0138f69

Please # to comment.