2014-09-09, 05:13 PM
Report to juventiner
Today, i have download plugins Google Analytics by juventiner, install on mybb forum (1.8) but not have complete
i look your code in plugins and i have simple changes:
inc/plugins/googleanalytics.php
Lines 18:
start from line 84:
Below is full code i had edit:
bonus to vietnamese user: vietnamese language pack for this plugins:
create file inc/languages/vietnamese/admin/googleanalytics.lang.php insert code:
Nice day to all!
Today, i have download plugins Google Analytics by juventiner, install on mybb forum (1.8) but not have complete
i look your code in plugins and i have simple changes:
inc/plugins/googleanalytics.php
Lines 18:
$lang->load('favicons');
replace: $lang->load('googleanalytics');
because you not input correct file name of pluginsstart from line 84:
function googleanalytics($page)
this is functions add google analytics to web-source, i think you can add google analytics in footer is better.Below is full code i had edit:
<?php
// Main Plugin file for the plugin Google Analytics
// © 2014 juventiner
// ----------------------------------------
// Last Update: 09.09.2014
// Edit by olalavui
if(!defined('IN_MYBB'))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook('pre_output_page','googleanalytics');
function googleanalytics_info()
{
global $lang;
$lang->load('googleanalytics');
return array
(
'name' => $lang->googleanalytics_info_name,
'description' => $lang->googleanalytics_info_desc,
'website' => 'http://community.mybb.com/user-32469.html',
'author' => 'juventiner',
'authorsite' => 'https://www.mybboard.de/forum/user-5490.html',
'version' => '1.1',
'compatibility' => '14*,16*,18*',
'guid' => '#'
);
}
// This function runs when the plugin is activated.
function googleanalytics_activate()
{
global $db, $lang;
$lang->load('googleanalytics');
$insertarray = array(
'name' => 'googleanalytics',
'title' => $lang->googleanalytics_settings_name,
'description' => $lang->googleanalytics_settings_desc,
'disporder' => 35,
'isdefault' => 0,
);
$gid = $db->insert_query("settinggroups", $insertarray);
$insertarray = array(
'name' => 'googleanalytics_status',
'title' => $lang->googleanalytics_settings_status_name,
'description' => $lang->googleanalytics_settings_status_desc,
'optionscode' => 'yesno',
'value' => 'no',
'disporder' => 1,
'gid' => $gid
);
$db->insert_query("settings", $insertarray);
$insertarray = array(
'name' => 'googleanalytics_ID',
'title' => $lang->googleanalytics_settings_url_name,
'description' => $lang->googleanalytics_settings_url_desc,
'optionscode' => 'text',
'value' => '',
'disporder' => 2,
'gid' => $gid
);
$db->insert_query("settings", $insertarray);
rebuild_settings();
}
// This function runs when the plugin is deactivated.
function googleanalytics_deactivate(){
global $db;
$db->delete_query("settings", "name IN('googleanalytics_status','googleanalytics_ID')");
$db->delete_query("settinggroups", "name IN('googleanalytics')");
}
function googleanalytics($page)
{
global $mybb;
if($mybb->settings['googleanalytics_status'] == 1)
{
$page=str_replace("</body>","<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '".$mybb->settings['googleanalytics_ID']."', 'auto');
ga('send', 'pageview');
</script>
</body>",$page);
}
return $page;
}
?>
bonus to vietnamese user: vietnamese language pack for this plugins:
create file inc/languages/vietnamese/admin/googleanalytics.lang.php insert code:
<?php
// Language file (Vietnamese) for MyBB Plugin Google Analytics
// © 2014 juventiner
// translate by olalavui (http://community.mybb.com/user-16855.html)
// ---------------------------------------------------
// Last Update: 09.09.2014
$l['googleanalytics_info_name'] = 'Google Analytics';
$l['googleanalytics_info_desc'] = 'Plugins này hỗ trợ bạn chèn code Google Analytics vào diễn đàn MyBB của bạn.';
$l['googleanalytics_settings_name'] = 'Thiết lập Google Analytics';
$l['googleanalytics_settings_desc'] = 'Tại đây bạn có thể thiết lập cấu hình Google Analytics trên website';
$l['googleanalytics_settings_status_name'] = 'Bật Google Analytics';
$l['googleanalytics_settings_status_desc'] = 'Hãy kích hoạt để được sử dụng tiện ích này';
$l['googleanalytics_settings_url_name'] = 'Google Analytics ID';
$l['googleanalytics_settings_url_desc'] = 'Hãy điền vào Google Analytics ID của bạn. ID có dạng \"UA-7397872-4\"';
?>
Nice day to all!