<?php
if(!defined("IN_MYBB"))
die("This file cannot be accessed directly.");
$plugins->add_hook('admin_load', 'gtmetrix_admin');
$plugins->add_hook('admin_tools_menu', 'gtmetrix_admin_tools_menu');
$plugins->add_hook('admin_tools_action_handler', 'gtmetrix_admin_tools_action_handler');
$plugins->add_hook('admin_tools_permissions', 'gtmetrix_admin_permissions');
function gtmetrixformybb_info()
{
return array(
"name" => "GTmetrix for MyBB",
"description" => "This plugin helps in development and a faster experience for your forum with GTMetrix",
"website" => "http://hasaezs.com",
"author" => "Steeep",
"authorsite" => "http://hasaezs.com",
"version" => "1.0",
"guid" => "",
"compatibility" => "16*"
);
}
function gtmetrixformybb_activate()
{
global $db;
$insertarray = array(
'name' => 'gtmetrix',
'title' => 'GTmetrix',
'description' => "Settings for GTmetrix",
'disporder' => 100,
);
$gid = $db->insert_query("settinggroups", $insertarray);
$setting0 = array(
"name" => "gtmetrix_email",
"title" => "Mail of GTmetrix",
"description" => "Enter here the email used in GTMetrix",
"optionscode" => "text",
"value" => "",
"disporder" => 1,
"gid" => $gid
);
$db->insert_query("settings", $setting0);
$setting1 = array(
"name" => "gtmetrix_api_key",
"title" => "API key of GTmetrix",
"description" => "Enter here the API key used in GTMetrix",
"optionscode" => "text",
"value" => "",
"disporder" => 2,
"gid" => $gid
);
$db->insert_query("settings", $setting1);
rebuild_settings();
}
function gtmetrixformybb_deactivate()
{
global $db;
$query = $db->query("SELECT gid FROM ".TABLE_PREFIX."settinggroups WHERE name='gtmetrix'");
$g = $db->fetch_array($query);
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE gid='{$g['gid']}'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE gid='{$g['gid']}'");
rebuild_settings();
}
function gtmetrix_admin_tools_menu(&$sub_menu)
{
$sub_menu[] = array('id' => 'gtmetrix', 'title' => 'GTmetrix', 'link' => 'index.php?module=tools-gtmetrix');
}
function gtmetrix_admin_tools_action_handler(&$actions)
{
$actions['gtmetrix'] = array('active' => 'gtmetrix', 'file' => 'gtmetrix');
}
function gtmetrix_admin_permissions(&$admin_permissions)
{
$admin_permissions['gtmetrix'] = "Can manage GTMetrix?";
}
function gtmetrix_admin()
{
global $page, $run_module, $action_file;
if($run_module == 'tools' && $action_file == 'gtmetrix')
{
$page->add_breadcrumb_item('GTmetrix', 'index.php?module=tools-gtmetrix');
$page->output_header('GTmetrix');
$page->output_footer();
exit;
}
}