Difference between revisions of "Plugin API"
(Misc Plugin API functions (may need to split them into smaller blocks)) |
(→Moderation / Submission) |
||
(14 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
Geeklog's [[Plugin API]] defines the interface between the core Geeklog code and the plugins. From Geeklog's point of view, all the Plugin API functions are called <code>PLG_something</code>, which will result in a function <code>plugin_something_foo</code> being called in the "foo" plugin (if it exists - all the API functions are optional). | Geeklog's [[Plugin API]] defines the interface between the core Geeklog code and the plugins. From Geeklog's point of view, all the Plugin API functions are called <code>PLG_something</code>, which will result in a function <code>plugin_something_foo</code> being called in the "foo" plugin (if it exists - all the API functions are optional). | ||
+ | |||
+ | Please note that there isn't always a one-to-one relationship between a <code>PLG_</code> function and a <code>plugin_</code> function. For example, <code>PLG_uninstall</code> will call either <code>plugin_uninstall_</code> or <code>plugin_autouninstall_</code>, whichever is implemented. Other functions may not even get through to the plugin, e.g. <code>PLG_afterSaveSwitch</code>. | ||
For details about Plugin API functions that are not documented yet, please refer to the documented source code of [http://project.geeklog.net/src/Geeklog/_system---lib-plugins.php.html lib-plugins.php] | For details about Plugin API functions that are not documented yet, please refer to the documented source code of [http://project.geeklog.net/src/Geeklog/_system---lib-plugins.php.html lib-plugins.php] | ||
Line 31: | Line 33: | ||
|Plugin should upgrade itself | |Plugin should upgrade itself | ||
|} | |} | ||
+ | |||
+ | Also see [[Plugin Autoinstall]]. | ||
Line 59: | Line 63: | ||
|plugin_submissioncount_ | |plugin_submissioncount_ | ||
|Return the number of items in the plugin's submission queue | |Return the number of items in the plugin's submission queue | ||
+ | |- | ||
+ | |plugin_submissionsaved_ | ||
+ | |Notify plugins that a user submitted something | ||
+ | |- | ||
+ | |plugin_submissiondeleted_ | ||
+ | |Notify plugins that an admin deleted a submission | ||
|- | |- | ||
|plugin_submit_ | |plugin_submit_ | ||
Line 64: | Line 74: | ||
|} | |} | ||
− | Also see [[Adding Moderation Capability]]. | + | Also see [[Adding Moderation Capability]] and [[Moderation Functions]]. |
− | |||
= Comments = | = Comments = | ||
Line 84: | Line 93: | ||
|plugin_getcommenturlid_ | |plugin_getcommenturlid_ | ||
|Provide URL of page to view comments and the unique identifier | |Provide URL of page to view comments and the unique identifier | ||
+ | |- | ||
+ | |plugin_getwhatsnewcomment_ | ||
+ | |Return the new plugin comments for the What's New block and the User Profile | ||
|- | |- | ||
|plugin_savecomment_ | |plugin_savecomment_ | ||
Line 90: | Line 102: | ||
Note that these are the only Comment API functions still in use. Also see [[Integrating the Comment Engine]]. | Note that these are the only Comment API functions still in use. Also see [[Integrating the Comment Engine]]. | ||
− | |||
= Statistics = | = Statistics = | ||
Line 126: | Line 137: | ||
Plugin authors are encouraged to [[Using Geeklog's Improved Search Engine|Use Geeklog's Improved Search Engine]], available as of Geeklog 1.6.0. | Plugin authors are encouraged to [[Using Geeklog's Improved Search Engine|Use Geeklog's Improved Search Engine]], available as of Geeklog 1.6.0. | ||
− | For backward compatibility with older Geeklog versions, also see [[Using Geeklog's Search Engine | + | For backward compatibility with older Geeklog versions, also see [[Using Geeklog's Search Engine]]. |
Line 140: | Line 151: | ||
|plugin_getadminoption_ | |plugin_getadminoption_ | ||
|Get entries for the [[Admins Block]] | |Get entries for the [[Admins Block]] | ||
+ | |- | ||
+ | |[[PLG_getplugin_getConfigTooltip|plugin_getconfigtooltip_]] | ||
+ | |Returns tooltip information for the Configuration | ||
|- | |- | ||
|[[PLG_getDocumentationUrl|plugin_getdocumentationurl_]] | |[[PLG_getDocumentationUrl|plugin_getdocumentationurl_]] | ||
Line 174: | Line 188: | ||
|Add template variables to the standard templates, e.g. site header, articles, ... | |Add template variables to the standard templates, e.g. site header, articles, ... | ||
|} | |} | ||
− | |||
= User = | = User = | ||
Line 242: | Line 255: | ||
'''Note:''' These API functions are used by plugins ''implementing'' a spam filter, i.e. they are implemented by the [[Spam-X Plugin]]. To filter spam in your plugin, see [[Filtering Spam with Spam-X]]. | '''Note:''' These API functions are used by plugins ''implementing'' a spam filter, i.e. they are implemented by the [[Spam-X Plugin]]. To filter spam in your plugin, see [[Filtering Spam with Spam-X]]. | ||
+ | |||
+ | = Blocks = | ||
+ | |||
+ | {| border="1" cellpadding="5" | ||
+ | ! API Function | ||
+ | ! Description | ||
+ | |- | ||
+ | |plugin_centerblock_ | ||
+ | |Display a centerblock | ||
+ | |- | ||
+ | |plugin_getBlocks_ | ||
+ | |Provide [[Dynamic Blocks|dynamically created blocks]] | ||
+ | |- | ||
+ | |plugin_getBlocksConfig_ | ||
+ | |Provide [[Dynamic Blocks|information about dynamic blocks]] for the Blocks Manager | ||
+ | |- | ||
+ | |plugin_getwhatsnew_ | ||
+ | |Provide content for the [[What's New Block]] | ||
+ | |- | ||
+ | |plugin_whatsnewsupported_ | ||
+ | |Return headline and byline for the [[What's New Block]] | ||
+ | |} | ||
= Misc = | = Misc = | ||
Line 251: | Line 286: | ||
|plugin_autotags_ | |plugin_autotags_ | ||
|Provide or replace autotags | |Provide or replace autotags | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
|- | |- | ||
|[[PLG_configChange|plugin_configchange_]] | |[[PLG_configChange|plugin_configchange_]] | ||
Line 263: | Line 292: | ||
|[[PLG_getItemInfo|plugin_getiteminfo_]] | |[[PLG_getItemInfo|plugin_getiteminfo_]] | ||
|Provide information about an item | |Provide information about an item | ||
+ | |- | ||
+ | |plugin_getrelateditems_ | ||
+ | |Return related items for an item or list of topics | ||
|- | |- | ||
|plugin_group_changed_ | |plugin_group_changed_ | ||
Line 269: | Line 301: | ||
|plugin_handlepingoperation_ | |plugin_handlepingoperation_ | ||
|Accept or delete a Trackback or Pingback | |Accept or delete a Trackback or Pingback | ||
+ | |- | ||
+ | |[[PLG_itemSaved#PLG_itemDeleted|plugin_itemdeleted_]] | ||
+ | |An item was deleted | ||
|- | |- | ||
|plugin_itemdisplay_ | |plugin_itemdisplay_ | ||
|An item is about to be displayed | |An item is about to be displayed | ||
− | |||
− | |||
− | |||
|- | |- | ||
|plugin_itemPreSave_ | |plugin_itemPreSave_ | ||
Line 281: | Line 313: | ||
|[[PLG_itemSaved|plugin_itemsaved_]] | |[[PLG_itemSaved|plugin_itemsaved_]] | ||
|Geeklog saved an item | |Geeklog saved an item | ||
− | |||
− | |||
− | |||
|- | |- | ||
|[[PLG_pluginStateChange|plugin_pluginstatechange_]] | |[[PLG_pluginStateChange|plugin_pluginstatechange_]] |
Latest revision as of 18:57, 4 July 2013
Geeklog's Plugin API defines the interface between the core Geeklog code and the plugins. From Geeklog's point of view, all the Plugin API functions are called PLG_something
, which will result in a function plugin_something_foo
being called in the "foo" plugin (if it exists - all the API functions are optional).
Please note that there isn't always a one-to-one relationship between a PLG_
function and a plugin_
function. For example, PLG_uninstall
will call either plugin_uninstall_
or plugin_autouninstall_
, whichever is implemented. Other functions may not even get through to the plugin, e.g. PLG_afterSaveSwitch
.
For details about Plugin API functions that are not documented yet, please refer to the documented source code of lib-plugins.php
Contents
Installation
API Function | Description |
---|---|
plugin_autouninstall_ | Plugin should provide data for uninstallation |
plugin_chkVersion_ | Called to check if a plugin upgrade is required |
plugin_enablestatechange_ | Inform plugin that it's about to be enabled or disabled |
plugin_install_ | (not currently used) |
plugin_migrate_ | Site migration underway; plugin should migrate its data |
plugin_uninstall_ | Plugin should uninstall itself |
plugin_upgrade_ | Plugin should upgrade itself |
Also see Plugin Autoinstall.
Moderation / Submission
API Function | Description |
---|---|
plugin_ismoderator_ | Check to see if the current user is a moderator for this plugin |
plugin_itemlist_ | Provide information to build the list of items in the plugin's submission queue |
plugin_moderationapprove_ | Approve an item in the plugin's submission queue |
plugin_moderationdelete_ | Remove an item from the plugin's submission queue |
plugin_moderationvalues_ | Set plugin-specific moderation values |
plugin_savesubmission_ | Save an item in the plugin's submission queue |
plugin_submissioncount_ | Return the number of items in the plugin's submission queue |
plugin_submissionsaved_ | Notify plugins that a user submitted something |
plugin_submissiondeleted_ | Notify plugins that an admin deleted a submission |
plugin_submit_ | Display the plugin's submission form |
Also see Adding Moderation Capability and Moderation Functions.
Comments
API Function | Description |
---|---|
plugin_commentPreSave_ | Called before a comment is saved |
plugin_deletecomment_ | Delete a comment |
plugin_displaycomment_ | Display one or several comment(s) |
plugin_getcommenturlid_ | Provide URL of page to view comments and the unique identifier |
plugin_getwhatsnewcomment_ | Return the new plugin comments for the What's New block and the User Profile |
plugin_savecomment_ | Save a comment |
Note that these are the only Comment API functions still in use. Also see Integrating the Comment Engine.
Statistics
API Function | Description |
---|---|
plugin_showstats_ | Provide statistics information (summary and specifics) |
plugin_statssummary_ | Provide statistics for the summary only |
Also see Extending Site Statistics with your plugin and Stats Function.
Search
API Function | Description |
---|---|
plugin_dopluginsearch_ | Perform search (v1 API) or provide search details and let Geeklog perform the search (v2 API) |
plugin_searchtypes_ | Provide entries for the "type" dropdown on the Advanced Search page |
plugin_supportsexpandedsearch_ | (not used any more) |
Plugin authors are encouraged to Use Geeklog's Improved Search Engine, available as of Geeklog 1.6.0.
For backward compatibility with older Geeklog versions, also see Using Geeklog's Search Engine.
UI and Templates
API Function | Description |
---|---|
plugin_cclabel_ | Get entry for the "Command and Control" page |
plugin_getadminoption_ | Get entries for the Admins Block |
plugin_getconfigtooltip_ | Returns tooltip information for the Configuration |
plugin_getdocumentationurl_ | Link to plugin documentation |
plugin_getheadercode_ | Add code, etc. to the HTML <head> section, e.g. meta tags
|
plugin_geticon_ | Provide URL of the plugin's icon |
plugin_getmenuitems_ | Add entries to the header menu |
plugin_getuseroption_ | Get entries for the User Functions Block |
plugin_profileblocksdisplay_ | Add template variables when displaying a block on the user profile page |
plugin_profileblocksedit_ | Add template variables to a block when editing the user profile |
plugin_profileextrassave_ | Save plugin-specific additions when saving a user's profile |
plugin_profilevariablesdisplay_ | Add template variables when displaying the user profile page |
plugin_profilevariablesedit_ | Add template variables when editing the user profile |
plugin_templatesetvars_ | Add template variables to the standard templates, e.g. site header, articles, ... |
User
API Function | Description |
---|---|
plugin_user_changed_ | A user's profile information or preferences changed |
plugin_user_create_ | A new user was created |
plugin_user_delete_ | A user is about to be deleted |
plugin_user_login_ | A user has logged in (using the login form) |
plugin_user_logout_ | A user has logged out (explicitly, i.e. using the "Log Out" link) |
Feeds
API Function | Description |
---|---|
plugin_feedElementExtensions_ | Get extension tags for a feed |
plugin_feedExtensionTags_ | Get meta tag extensions for a feed |
plugin_feedNSExtensions_ | Get namespace extensions for a feed |
plugin_feedupdatecheck_ | Plugin should check if a feed needs to be updated |
plugin_getfeedcontent_ | Get content of a plugin feed |
plugin_getfeednames_ | Get a list of feeds provided by the plugin |
Also see RSS API.
Spam Filter
API Function | Description |
---|---|
plugin_spamaction_ | Trigger action on recognized spam |
plugin_checkforSpam_ | Check if content is spam |
Note: These API functions are used by plugins implementing a spam filter, i.e. they are implemented by the Spam-X Plugin. To filter spam in your plugin, see Filtering Spam with Spam-X.
Blocks
API Function | Description |
---|---|
plugin_centerblock_ | Display a centerblock |
plugin_getBlocks_ | Provide dynamically created blocks |
plugin_getBlocksConfig_ | Provide information about dynamic blocks for the Blocks Manager |
plugin_getwhatsnew_ | Provide content for the What's New Block |
plugin_whatsnewsupported_ | Return headline and byline for the What's New Block |
Misc
API Function | Description |
---|---|
plugin_autotags_ | Provide or replace autotags |
plugin_configchange_ | A change was made in the Configuration for Geeklog or a plugin |
plugin_getiteminfo_ | Provide information about an item |
plugin_getrelateditems_ | Return related items for an item or list of topics |
plugin_group_changed_ | A group's information has changed or a new group was created |
plugin_handlepingoperation_ | Accept or delete a Trackback or Pingback |
plugin_itemdeleted_ | An item was deleted |
plugin_itemdisplay_ | An item is about to be displayed |
plugin_itemPreSave_ | Called before an item is saved |
plugin_itemsaved_ | Geeklog saved an item |
plugin_pluginstatechange_ | A plugin's state changed |
plugin_runScheduledTask_ | Run a task at a scheduled time (cronjob-like functionality) |
plugin_wsEnabled_ | Whether or not the plugin supports the Webservices API |