You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Some plugins may need to be invoked to perform certain tasks from time to time. For this reason plugins may register plugin events. These Events automatically initialize the plugin and invoke the desired callback method when triggered. The parameters passed to the callback method vary depending on the event invoked.

Adding Plugin Events

To add plugin events, simply return them from your plugin's getEvents() method.

/install_dir/plugins/my_plugin.php
<?php
class MyPlugin extends Plugin {

	...

	public function getEvents() {
		return array(
			array(
				'event' => "preaction",
				'callback' => array("this", "run")
			)
			// Add multiple events here
		);
	}

	public function run() {
		// This will execute when the "preaction" event is triggered
	}
}
?>

 

 

  • No labels