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.
PHP Code:
$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.:
PHP Code:
* 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:
PHP Code:
* name: Vote
* description: Adds voting ability to posted stories.
* version: 1.5
* folder: vote
* class: Vote
* type: vote
PHP Code:
* 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.
Bookmarks