folder structure:
include/plugins/test-plugin
-- plugin.php
-- config.php
-- ai_superpower.php
Content of: plugin.php
<?php return array(
'id' => 'test:ai_superpower', # notrans
'version' => '0.1',
'name' => 'AI Superpower',
'author' => 'NameSurname',
'description' => 'Description..',
'url' => 'https://mysite.com',
'plugin' => 'ai_superpower.php:ai_superpower',
);
Content of: config.php
<?php
require_once INCLUDE_DIR . 'class.plugin.php';
class ai_superpowerPluginConfig extends PluginConfig {
function translate() {
if (!method_exists('Plugin', 'translate')) {
return array(
function ($x) { return $x; },
function ($x, $y, $n) { return $n != 1 ? $y : $x; },
);
}
return Plugin::translate('ai_superpower');
}
function getOptions() {
list($__, $_N) = self::translate();
return array(
'ri' => new SectionBreakField(array(
'label' => $__(
'Configuration Unnecessary, simply disable the plugin to remove the injected JavaScript.'
)
)),
't' => new SectionBreakField(array(
'label' => $__(
'Source: https://mysite.com/'
)
))
);
}
}
Content of: ai_superpower.php
<?php
require_once (INCLUDE_DIR . 'class.signal.php');
require_once ('config.php');
class ai_superpower extends Plugin {
var $config_class = 'ai_superpowerPluginConfig';
function isMultiInstance() {
return false; // one istance
}
private function injectJSHeader() {
global $ost;
$ost->addExtraHeader('<!-- JavascriptInject -->');
error_log('AI Superpower: The injectJSHeader function was executed.');
}
function bootstrap(){
// Now, what do we want to do?
error_log("Hello Server logs, from our example Plugin!");
$this->injectJSHeader();
}
function uninstall(&$errors) {
$errors = array ();
global $ost;
$ost->alertAdmin ( 'Plugin disinstallato', 'Configurazione eliminata.', true );
parent::uninstall ( $errors );
}
public function getForm() {
return array ();
}
}