How to create a plugin

From Osclass Enterprise
Jump to: navigation, search

Osclass Enterprise functionalities can be extended via plugins. If you want to learn how to create them, please read our Plugins page.

Plugins files structure

Each plugin must consist in one plugin folder (you can call it whatever you want) and one index.php file, at least. You can add several files and libraries. Plugins use Hooks to trigger functions at several places of the Osclass Enterprise code.

Making a plugin installable

To make a plugin installable you must put this function at the end of the index.php


osc_register_plugin(osc_plugin_path(__FILE__), 'custom_function_call_after_install') ;


Usage of hooks

To use a hook, add the following code to your plugin file :


osc_add_hook('hook_name', 'function_name');


Substitute 'hook_name' by the name of the hook you want to attach 'function_name', and 'function_name' with the name of your function.

Special hooks

There are some special hooks:

// This is a hack to show a Configure link at plugins table (you can also use some other hook to show a custom option panel);


osc_add_hook(osc_plugin_path(__FILE__) . "_configure", 'function_name');


// This is a hack to show an Uninstall link at plugins table (you can also use some other hook to show a custom option panel);


osc_add_hook(osc_plugin_path(__FILE__) . "_uninstall", 'function_name');


List of Hooks

Here's a detailed list of Hooks explaining when they are triggered and which arguments are passed to the target functions.


More information

Any doubts or comments can be posted on our Development Forum.