Plugins

From Habari Project

Jump to: navigation, search

User Manual Page

This page is intended to be documentation for Habari end users.

If you're a developer, there is more detailed information available about in the development and core sections.

Related Development Page

Contents

Plugins are intended to be extensions of the core functionality of Habari. Your installation will come with several, community developed plugins, or you may download other, community and individually developed plugins. Eventually, a repository on the official site will house freely available plugins, until then, you can check out the Available Plugins.

Installation & Activation

The directory structure must be kept in place, that is, do not upload just the php files of the plugin, rather, the entire directory, even if only one file exists.

System Plugins vs User Plugins

Core plugins are installed in /system/plugins. User installed plugins should be installed in /user/plugins/. This system allows for upgrades, without having to touch the /user directory at all. If a plugin exists in both locations, the /user/plugins will override the system version. Note, all of the files and directories of a plugin must live in the /user/plugin directory, it will not pull from both.

To activate and configure your plugins navigate your browser to /admin/plugins, and a list of all plugins in your user directory should be available. To active or deactivate a plugin, simply click the button to the right of the plugin name. Some plugins also provide configuration settings, clicking the configure link will open the options below the list of your installed plugins (but note that the interface for plugin configuration is still in development). Note that a "sandboxing" function exists to check a plugins syntax before being activated. If any errors exist, the plugin will not be available for activation. If this occurs, you should contact the plugin author, or check for a newer version.

Enabling the Plugin

Some features provided by plugins will be enabled without you doing anything other than activating the plugin. However, some plugins will require adding code to your active theme to output some data. Generally speaking, the plugin author should provide documentation for this, however, in most cases the plugin sets a variable and adds it to the $theme instance, which represents the active theme. Within the template where you want the plugin's data displayed, you simply echo that variable. This is done so that in the future, when other theme engines are added, specific PHP code isn't required for the plugin to work with that theme engine. If a plugin sets the variable $my_twitter, in the raw PHP engine you would add <?php echo $my_twitter; ?> to the template where you want to show the data. As other engines are added, this will be updated to reflect those as well.

Checking for Plugins in Themes

You can use a conditional statement to see if a particular plugin is active, and if so, do something, else, do something else.

This is not recommended for most purposes, especially in template files, because theme functions provide more functionality and have the plugin detection built-in, and Theme Dependencies allow you to specify Theme Functions and versions that must be present for your theme to work properly before it's even activated.

To test if a plugin is present, use the following function:

<?php Plugins::is_loaded(); ?>

You need to pass at least one variable to the function, the $name. $name can either be from the plugin info, or the class. You can also pass a version number, however this is optional. So for example, if you want to check to see if the Pingback plugin is active, and is at least version 1.0, you would do something to the effect of:

<?php if (Plugins::is_loaded('pingback','1.0')) {
  //do something
}
else {
  //something instead
}
 
?>

However, if you do not need to test against a version, you simply need :

<?php if (Plugins::is_loaded('pingback')) {
 //do something
}
else {
  //something instead
}
 
?>
Personal tools
This is a cached copy of the requested page, and may not be up to date.

Sorry! This site is experiencing technical difficulties.
Try waiting a few minutes and reloading.

(Can't contact the database server: Access denied for user 'habari'@'localhost' to database 'habari_wiki' (localhost))


You can try searching via Google in the meantime.
Note that their indexes of our content may be out of date.