This wiki is under constant development, however pages are always missing. Create an account and login to be able to edit/create pages here.
 

Plugin API

This page documents the extension API (application programming interface) hooks in Lilina and demonstrates how to use them when developing plugins.

This page assumes you have read the Developing Plugins guide first, which gives a general guide on how to write a plugin. This page specifically deals the API of “Actions” and “Filters”, collectively known as “Hooks”, that your plugin uses to interface with Lilina's core system.

Note: this system is only valid for Lilina 1.0. Previous versions do not contain a plugin system of any sort.

Hooks

Hooks are provided by Lilina's core system to allow your plugin to 'hook into' the rest of Lilina; that is, to use the functions in your plugin to effect content or run actions. There are two kinds of hooks:

  1. Actions: Actions are hooks that the core system runs at specific times during execution, or when specific events happen. Your plugin can specify any number of functions to run at these times by registering it with the API.
  2. Filters: Filters are hooks that Lilina uses to modify text, settings or feeds. For example, HTMLPurifier's sanitizer uses the return_output hook to effect the content of each item. Your plugin can specify that one or more of its PHP functions is executed to modify specific types of text at these times, using the Filter API.

Actions

Actions are triggered by specific events that take place in Lilina, such as changing themes or displaying a page of the admin panel. Your plugin can respond to the event by executing a PHP function, which might do one or more of the following:

  • Modify settings
  • Display an update notice
  • Add social bookmarking tools to each item

The method to doing this in your plugin is:

  1. Create the function you want to be called
  2. Hook the function into Lilina using register_action
  3. Save the function into a plugin file and activate it using the admin page

Creating an Action Function

Firstly, create the plugin file which you are you going to put the action function in. Then create the function that contains the action you want to do. For example, to add a Digg link to the bottom of each entry, you use the following function:

function digg_link($item) {
	echo '<a href="http://digg.com/submit?phase=2&url=', $item['link'], '">Digg this entry</a>';
}

Hooking into Lilina

Once your function is defined, you will need to register, or hook, it with Lilina. This is done using the register_action function in the global section of your plugin (i.e. outside of any functions):

register_action('hook_name', 'function_name', [accepted_args]);

where:

  • hook_name (string) is the name of an action hook you want to associate your function with
  • function_name (string) is the name of the function you want to be executed when hook_name occurs. This can be any type of function, such as built in (such as usort), one of Lilina's core functions (such as lilina_parse_html) or your own function you have defined
  • accepted_args (int) is the number of arguments your function can accept (default of 0)

For the above example, we would use the code:

register_action('digg_link', 'river_entry', 1);

Activating your plugin

The final step is to activate your action plugin. Currently, this must be done with manual require_once calls, however it is being added into the administration panel before the official release of 1.0.

Action hooks

See the reference list for action hooks for more action hooks and what versions they are available in.

Filters

More coming soon

Based on the WordPress codex's page of the same name

 
hooks/start.txt · Last modified: 2007/12/31 19:15 by Ryan McCue