Hotaru Docs

 [həʊdɒks]

Testing for Active Plugins

Hotaru provides a built-in method for checking if another plugin is enabled. This is especially helpful if your own plugin depends on that plugin.

$h->isActive('avatar'); // is the a plugin of type avatar enabled?
 
$h->isActive('gravatar'); // is the Gravatar plugin enabled?

At the top of every plugin is a comment block, and some plugins, such as Gravatar, include both a plugin folder and a plugin type, i.e.:

* name: Gravatar
 * description: Enables Gravatar avatars for users
 * version: 0.8
 * folder: gravatar
 * class: Gravatar
 * type: avatar
 * requires: users 1.1

The isActive method in Hotaru.php takes a single parameter, e.g. "avatar" and returns true if there is a plugin with that type. If not, it then checks to see if there is a plugin with that folder name. If so, it returns true, otherwise false.

This is useful when there are alternative plugins available. For example, different voting plugins are of the same type:

* name: Vote
 * description: Adds voting ability to posted stories.
 * version: 1.5
 * folder: vote
 * class: Vote
 * type: vote
* name: Up Down Voting
 * description: Adds voting ability to posted stories.
 * version: 0.3
 * folder: updown_voting
 * class: UpdownVoting
 * type: vote

This way you can switch plugins without breaking anything that tests for a type "vote" plugin.


Considerations

If you have two plugins installed with the same plugin type, the isActive function will return the "plugin_enabled" status of the first one in the plugin order. This is significant because if the first is disabled, Hotaru will return false to the isActive function call. To avoid this glitch, the active plugin should be positioned above inactive plugins with the same plugin type, or simply uninstall inactive plugins altogether.

Getting StartedDesign and LayoutPlugin DevelopmentAdvanced TopicsFunction ReferenceTroubleshooting